Re: av7110 and budget_av are broken!

2010-05-16 Thread Oliver Endriss
Hi Douglas,

On Sunday 16 May 2010 07:09:21 Douglas Schilling Landgraf wrote:
 Please hg pull -u, now should include the change that you are looking for.

Thanks, now the driver works again. :-)

Regards,
Oliver

-- 

VDR Remote Plugin 0.4.0: http://www.escape-edv.de/endriss/vdr/
4 MByte Mod: http://www.escape-edv.de/endriss/dvb-mem-mod/
Full-TS Mod: http://www.escape-edv.de/endriss/dvb-full-ts-mod/

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Hauppage Nova-500-td problems

2010-05-16 Thread Pshem Kowalczyk
Hi,

I've recently bought Hauppage nova-500-td for my mythtv backend. The
card works mostly fine, but every now and then it looks like it
doesn't tune to the channel properly (I think) - video and sound
remain garbled for prolonged periods of time (2-5 minutes), but
ultimately recover. This usually happens when the other tuner on the
card is tuned to the same mux. Signal quality I get is around 70% and
about 2.5dB of signal to noise (as reported by mythtv), but when the
issue occurs regardless of what the numbers show.

I'm not entirely sure if that's a hardware or software issue (have no
windows based pc to try with), but I already got the the card replaced
once, so if it's hardware it might be something else then the card
itself. I know that some other people reported issues as well as
suggested patches, but I haven't found anything conclusive. Currently
I run the hg tip version of v4l-dvb with 2.6.32 kernel on gentoo.

I would like to know if anyone else experienced something similar
issues, and probably the more important part -how can I help to
troubleshoot and debug the problem?

kind regards
Pshem
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: RFC: behavior of QUERYSTD when no signal is present

2010-05-16 Thread Hans Verkuil
On Sunday 09 May 2010 11:23:05 Hans Verkuil wrote:
 What is VIDIOC_QUERYSTD supposed to do when there is no signal?
 
 The spec says this:
 
 The hardware may be able to detect the current video standard automatically.
 To do so, applications call VIDIOC_QUERYSTD with a pointer to a v4l2_std_id
 type. The driver stores here a set of candidates, this can be a single flag
 or a set of supported standards if for example the hardware can only
 distinguish between 50 and 60 Hz systems. When detection is not possible or
 fails, the set must contain all standards supported by the current video
 input or output.
 
 The last sentence is the problem. There are several possibilities:
 
 1) The hardware is physically unable to detect the current video std. In that
 case this ioctl shouldn't be implemented at all.
 
 2) While detecting the std an error occurs (e.g. i2c read error). In that case
 the error should be returned.
 
 3) There is no input signal. Does that constitute 'detection is not possible 
 or
 fails'? If so, then all supported standards should be returned. But that seems
 very strange. After all, I did detect the standard: i.e. there is none, so I
 would say that QUERYSTD should return V4L2_STD_UNKNOWN (0).
 
 A quick check of the current state of affairs when no signal is present 
 reveals
 that:
 
 - saa7115, ks0127, saa7191 return 0 with std set to V4L2_STD_ALL
 - adv7180, vpx3220 return 0 with std set to V4L2_STD_UNKNOWN
 - saa7110 returns 0 with std set to the current std
 - bt819 and bttv do not handle this case at all, and just pick 50 Hz or 60 Hz
 - tvp514x returns -EINVAL.
 
 Lovely... :-)
 
 It is clear that applications currently have no hope in hell to use the output
 of querystd in a reliable manner. For all practical purposes the behavior of
 querystd when no signal is present is undefined.
 
 I would propose to specify that if no signal is present then QUERYSTD should
 return 0 with std V4L2_STD_UNKNOWN.

I received no comments, so I will prepare patches to implement this proposal.

Regards,

Hans

 It would also be consistent with QUERY_DV_PRESET where the preset DV_INVALID
 is returned in that case.
 
 If we decide to change it, then it is trivial to fix all drivers that 
 implement
 querystd.
 
 Comments?
 
   Hans
 
 

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG, part of Cisco
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Compro Videomate T750F Vista digital+analog support

2010-05-16 Thread semiRocket

On Mon, 10 May 2010 01:15:35 +0200, Emard davorem...@gmail.com wrote:


HI

This is even more cleanup from spaces into tabs
and replacing KEY_BACKSPACE with KEY_BACK
which I think is more appropriate for this remote.

compro t750f patch v17

About the remote - I noticed 2-10% of the keypresses
are not recognized, seems like it either looses packets
or saa7134 gpio should be scanned faster/better/more_reliable?
I think this may be the issue with other 7134 based
remotes too

Best Regards, Emard



Hi Davor,


Unfortunately it doesn't work for me. It can't load firmware like before,  
I've attached patch against recent hg tree I applied manually (without IR  
code part) and dmesg output.


In tvtime it shows black screen in PAL mode, if switch to SECAM, it's  
still black screen but with some random flickering occurring represented  
by horizontal red/green lines. No white/black dots noise present.


Thanks,
Samuel
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Compro Videomate T750F Vista digital+analog support

2010-05-16 Thread Samuel Rakitničan

Sorry, here's the attachments.


On Sun, 16 May 2010 12:38:03 +0200, semiRocket semiroc...@gmail.com  
wrote:



On Mon, 10 May 2010 01:15:35 +0200, Emard davorem...@gmail.com wrote:


HI

This is even more cleanup from spaces into tabs
and replacing KEY_BACKSPACE with KEY_BACK
which I think is more appropriate for this remote.

compro t750f patch v17

About the remote - I noticed 2-10% of the keypresses
are not recognized, seems like it either looses packets
or saa7134 gpio should be scanned faster/better/more_reliable?
I think this may be the issue with other 7134 based
remotes too

Best Regards, Emard



Hi Davor,


Unfortunately it doesn't work for me. It can't load firmware like  
before, I've attached patch against recent hg tree I applied manually  
(without IR code part) and dmesg output.


In tvtime it shows black screen in PAL mode, if switch to SECAM, it's  
still black screen but with some random flickering occurring represented  
by horizontal red/green lines. No white/black dots noise present.


Thanks,
Samuel

--
Lorem ipsum

hg-20100516.diff
Description: Binary data


dmesg
Description: Binary data


Re: av7110 and budget_av are broken!

2010-05-16 Thread Mauro Carvalho Chehab
Oliver Endriss wrote:
 On Sunday 16 May 2010 03:53:48 hermann pitton wrote:
 Am Samstag, den 15.05.2010, 22:33 -0300 schrieb Douglas Schilling
 Landgraf:
 Hello Oliver,

 On Sat, May 15, 2010 at 8:06 PM, Oliver Endriss o.endr...@gmx.de wrote:
 On Wednesday 21 April 2010 11:44:16 Oliver Endriss wrote:
 On Wednesday 21 April 2010 08:37:39 Hans Verkuil wrote:
 Am 22.3.2010 20:34, schrieb e9hack:
 Am 20.3.2010 22:37, schrieb Hans Verkuil:
 On Saturday 20 March 2010 17:03:01 e9hack wrote:
 OK, I know that. But does the patch I mailed you last time fix this
 problem
 without causing new ones? If so, then I'll post that patch to the 
 list.
 With your last patch, I've no problems. I'm using a a TT-C2300 and a
 Budget card. If my
 VDR does start, currently I've no chance to determine which module is
 load first, but it
 works. If I unload all modules and load it again, I've no problem. In
 this case, the
 modules for the budget card is load first and the modules for the FF
 loads as second one.
 Ping!!
 It's merged in Mauro's fixes tree, but I don't think those pending 
 patches
 have been pushed upstream yet. Mauro, can you verify this? They should be
 pushed to 2.6.34!
 What about the HG driver?
 The v4l-dvb HG repository is broken for 7 weeks...
 Hi guys,

 we have May 16th, and the HG driver is broken for 10 weeks now!

 History:
 - The changeset which caused the mess was applied on March 2nd:
  http://linuxtv.org/hg/v4l-dvb/rev/2eda2bcc8d6f

 - A fix is waiting at fixes.git since March 24th:
  
 http://git.linuxtv.org/fixes.git?a=commitdiff_plain;h=40358c8b5380604ac2507be2fac0c9bbd3e02b73

 Are there any plans to bring v4ldvb HG to an usable state?
 Yes, Now I will collect patches from devel and fixes tree. At least
 until we achieve a better approach on it.
 Sorry the delay.

 Sounds good? Any other suggestion?

 Let me work on it.

 Cheers
 Douglas

 Hi, Douglas and Oliver,

 just as a small comment.

 I have not been on latest rc1 and such rcs close to a release for some
 time.

 But I was for a long time and v4l-dvb can't be a substitute for such.
 
 Sorry, I do not want to cope with experimental kernels and their bugs on
 my systems. I need a stable and reliable platform, so that I can
 concentrate on 'my' bugs.
 
 Usually I update the kernel every 3..4 releases (which causes enough
 trouble due to changed features, interfaces etc).

I used to do it, but, in fact updating every release and following stable
worked better for me, since there are less changes at the features, making
easier to compile a new kernel that won't break anything.

Anyway, it is up to you to use whatever works better for you.

 
 Despite of getting more users for testing, on _that_ front does not
 happen such much currently, keeping v4l-dvb is mostly a service for
 developers this time.

 So, contributing on the backports and helping Douglas with such is
 really welcome.
 
 I confess that I do not know much about the tree handling procedures of
 the kernel. Imho it sounds crazy to have separate 'fixes' and
 'development' trees.

I'll change the procedures for 2.6.35. I'll basically opt for having
topic branches (for example, having a ngene branch), where all ngene patches
will be applied, updating master only after having those patches in kernel.
I'll likely create a stable branch, with the latest kernel, plus all patches
(like v2.6.34-v4l-dvb), to help people that want to develop using git.

The big problem when handling patches upstream is caused by rebasing a patch,
and the higher number of patches in a tree, the higher is the probability that
a rebase will needed to avoid breaking compilation on a bisect.

To give you an example, one big series of patches moved slab.h into each 
driver that uses malloc. If a new driver or c file that needs this include
on our series were added, to avoid breaking bisect, we need to go to the patch
that introduced this code, and add the include there. All patches after this
one needs to be rebased, when submitting upstream.

So, let's say that the original patch has 05a43 has, and the new patch has
a0342 (fictional numbers).

So, in the development branches, this patch is known as 05a43, where, on
upstream, this patch will be known as a0342.

If I rebase the development tree, all developers using git would need to rebase
their trees. If I don't rebase, after merging from upstream, this patch will
appear 2 times at the master branch history: as 05a43 and as a0342. To be worse,
on the next time I need to send patches upstream, this patch will appear again
on my pile of patches to be submitted, and I'll need to manually drop it.
Due to 2.6.33 merge, this problem is already present on our master branch. So,
I'll need to drop a big pile of patches on my next upstream pull request.
At each new kernel release, things would become worse.

With topic branches, things will hopefully become easier, as people can base 
their
trees on a topic branch. Also, we may have some topic branches based on a 

[PATCH 00/15] [RFCv2] [RFC] New control handling framework

2010-05-16 Thread Hans Verkuil
This RFC patch series adds the control handling framework and implements
it in ivtv and all subdev drivers used by ivtv.

It is a bare-bones implementation, so no sysfs or debugfs enhancements.

It is the second version of this framework, incorporating comments from
Laurent.

Changes compared to the first version:

- Updated the documentation, hopefully making it easier to understand.
- v4l2_ctrl_new_custom now uses a new v4l2_ctrl_config struct instead of
  a long argument list.
- v4l2_ctrl_g/s is now renamed to v4l2_ctrl_g/s_ctrl.
- The v4l2_ctrl.h header now uses kernel doc comments.
- Removed the 'strict validation' feature.
- Added a new .init op that allows you to initialize many of the v4l2_ctrl
  fields on first use. Required by uvc.
- No longer needed to initialize ctrl_handler in struct video_device. It
  will copy the ctrl_handler from struct v4l2_device if needed.
- Renamed the v4l2_sd_* helper functions to v4l2_subdev_*.

I decided *not* to rename the v4l2_ctrl struct. What does the struct describe?
A control. Period. So I really don't know what else to call it. Every other
name I can think of is contrived. It really encapsulates all the data and info
that describes a control and its state. Yes, it is close to struct v4l2_control,
but on the other hand any driver that uses this framework will no longer use
v4l2_control (or v4l2_ext_controls for that matter). It will only use v4l2_ctrl.
So I do not think there will be much cause for confusion here.

Anyway, comments are welcome.

Once this is in then we can start migrating all subdev drivers to this
framework, followed by all bridge drivers. Converted subdev drivers can
still be used by unconverted bridge drivers. Once all bridge drivers are
converted the subdev backwards compatibility code can be removed.

The same is true for the cx2341x module: both converted and unconverted
bridge drivers are supported. Once all bridge drivers that use this module
are converted the compat code can be removed from cx2341x (and that will
save about 1060 lines of hard to understand code).

Regards,

Hans

Hans Verkuil (15):
  v4l2: Add new control handling framework
  v4l2-ctrls: reorder 'case' statements to match order in header.
  Documentation: add v4l2-controls.txt documenting the new controls
API.
  v4l2: hook up the new control framework into the core framework
  saa7115: convert to the new control framework
  msp3400: convert to the new control framework
  saa717x: convert to the new control framework
  cx25840/ivtv: replace ugly priv control with s_config
  cx25840: convert to the new control framework
  cx2341x: convert to the control framework
  wm8775: convert to the new control framework
  cs53l32a: convert to new control framework.
  wm8739: convert to the new control framework
  ivtv: convert gpio subdev to new control framework.
  ivtv: convert to the new control framework

 Documentation/video4linux/v4l2-controls.txt |  600 +
 drivers/media/video/Makefile|2 +-
 drivers/media/video/cs53l32a.c  |  107 +-
 drivers/media/video/cx2341x.c   |  734 +--
 drivers/media/video/cx25840/cx25840-audio.c |  144 +--
 drivers/media/video/cx25840/cx25840-core.c  |  201 ++--
 drivers/media/video/cx25840/cx25840-core.h  |   23 +-
 drivers/media/video/ivtv/ivtv-controls.c|  275 +
 drivers/media/video/ivtv/ivtv-controls.h|6 +-
 drivers/media/video/ivtv/ivtv-driver.c  |   26 +-
 drivers/media/video/ivtv/ivtv-driver.h  |4 +-
 drivers/media/video/ivtv/ivtv-fileops.c |   23 +-
 drivers/media/video/ivtv/ivtv-firmware.c|6 +-
 drivers/media/video/ivtv/ivtv-gpio.c|   77 +-
 drivers/media/video/ivtv/ivtv-i2c.c |7 +
 drivers/media/video/ivtv/ivtv-ioctl.c   |   31 +-
 drivers/media/video/ivtv/ivtv-streams.c |   20 +-
 drivers/media/video/msp3400-driver.c|  248 ++---
 drivers/media/video/msp3400-driver.h|   16 +-
 drivers/media/video/msp3400-kthreads.c  |   16 +-
 drivers/media/video/saa7115.c   |  180 ++--
 drivers/media/video/saa717x.c   |  323 ++
 drivers/media/video/v4l2-common.c   |  479 +---
 drivers/media/video/v4l2-ctrls.c| 1844 +++
 drivers/media/video/v4l2-dev.c  |8 +-
 drivers/media/video/v4l2-device.c   |7 +
 drivers/media/video/v4l2-ioctl.c|   46 +-
 drivers/media/video/wm8739.c|  176 +--
 drivers/media/video/wm8775.c|   79 +-
 include/media/cx2341x.h |   81 ++
 include/media/cx25840.h |   11 +
 include/media/v4l2-ctrls.h  |  448 +++
 include/media/v4l2-dev.h|4 +
 include/media/v4l2-device.h |4 +
 include/media/v4l2-subdev.h |3 +
 35 files changed, 4351 insertions(+), 1908 deletions(-)
 create mode 100644 

[PATCH 02/15] [RFCv2] v4l2-ctrls: reorder 'case' statements to match order in header.

2010-05-16 Thread Hans Verkuil
To make it easier to determine whether all controls are added in v4l2-ctrls.c
the case statements inside the switch are re-ordered to match the header.

Signed-off-by: Hans Verkuil hverk...@xs4all.nl
Reviewed-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/video/v4l2-ctrls.c |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 6c97ff0..21bf740 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -266,6 +266,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 {
switch (id) {
/* USER controls */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
case V4L2_CID_USER_CLASS:   return User Controls;
case V4L2_CID_BRIGHTNESS:   return Brightness;
case V4L2_CID_CONTRAST: return Contrast;
@@ -296,28 +297,37 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_SHARPNESS:return Sharpness;
case V4L2_CID_BACKLIGHT_COMPENSATION:   return Backlight Compensation;
case V4L2_CID_CHROMA_AGC:   return Chroma AGC;
-   case V4L2_CID_CHROMA_GAIN:  return Chroma Gain;
case V4L2_CID_COLOR_KILLER: return Color Killer;
case V4L2_CID_COLORFX:  return Color Effects;
case V4L2_CID_AUTOBRIGHTNESS:   return Brightness, Automatic;
case V4L2_CID_BAND_STOP_FILTER: return Band-Stop Filter;
case V4L2_CID_ROTATE:   return Rotate;
case V4L2_CID_BG_COLOR: return Background Color;
+   case V4L2_CID_CHROMA_GAIN:  return Chroma Gain;
 
/* MPEG controls */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
case V4L2_CID_MPEG_CLASS:   return MPEG Encoder Controls;
+   case V4L2_CID_MPEG_STREAM_TYPE: return Stream Type;
+   case V4L2_CID_MPEG_STREAM_PID_PMT:  return Stream PMT Program ID;
+   case V4L2_CID_MPEG_STREAM_PID_AUDIO:return Stream Audio Program 
ID;
+   case V4L2_CID_MPEG_STREAM_PID_VIDEO:return Stream Video Program 
ID;
+   case V4L2_CID_MPEG_STREAM_PID_PCR:  return Stream PCR Program ID;
+   case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: return Stream PES Audio ID;
+   case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: return Stream PES Video ID;
+   case V4L2_CID_MPEG_STREAM_VBI_FMT:  return Stream VBI Format;
case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: return Audio Sampling 
Frequency;
case V4L2_CID_MPEG_AUDIO_ENCODING:  return Audio Encoding;
case V4L2_CID_MPEG_AUDIO_L1_BITRATE:return Audio Layer I Bitrate;
case V4L2_CID_MPEG_AUDIO_L2_BITRATE:return Audio Layer II Bitrate;
case V4L2_CID_MPEG_AUDIO_L3_BITRATE:return Audio Layer III 
Bitrate;
-   case V4L2_CID_MPEG_AUDIO_AAC_BITRATE:   return Audio AAC Bitrate;
-   case V4L2_CID_MPEG_AUDIO_AC3_BITRATE:   return Audio AC-3 Bitrate;
case V4L2_CID_MPEG_AUDIO_MODE:  return Audio Stereo Mode;
case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: return Audio Stereo Mode 
Extension;
case V4L2_CID_MPEG_AUDIO_EMPHASIS:  return Audio Emphasis;
case V4L2_CID_MPEG_AUDIO_CRC:   return Audio CRC;
case V4L2_CID_MPEG_AUDIO_MUTE:  return Audio Mute;
+   case V4L2_CID_MPEG_AUDIO_AAC_BITRATE:   return Audio AAC Bitrate;
+   case V4L2_CID_MPEG_AUDIO_AC3_BITRATE:   return Audio AC-3 Bitrate;
case V4L2_CID_MPEG_VIDEO_ENCODING:  return Video Encoding;
case V4L2_CID_MPEG_VIDEO_ASPECT:return Video Aspect;
case V4L2_CID_MPEG_VIDEO_B_FRAMES:  return Video B Frames;
@@ -330,16 +340,9 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: return Video Temporal 
Decimation;
case V4L2_CID_MPEG_VIDEO_MUTE:  return Video Mute;
case V4L2_CID_MPEG_VIDEO_MUTE_YUV:  return Video Mute YUV;
-   case V4L2_CID_MPEG_STREAM_TYPE: return Stream Type;
-   case V4L2_CID_MPEG_STREAM_PID_PMT:  return Stream PMT Program ID;
-   case V4L2_CID_MPEG_STREAM_PID_AUDIO:return Stream Audio Program 
ID;
-   case V4L2_CID_MPEG_STREAM_PID_VIDEO:return Stream Video Program 
ID;
-   case V4L2_CID_MPEG_STREAM_PID_PCR:  return Stream PCR Program ID;
-   case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: return Stream PES Audio ID;
-   case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: return Stream PES Video ID;
-   case V4L2_CID_MPEG_STREAM_VBI_FMT:  return Stream VBI Format;
 
/* CAMERA controls */
+   /* Keep the order of the 'case's the same as in videodev2.h! */
case V4L2_CID_CAMERA_CLASS: return Camera Controls;
case V4L2_CID_EXPOSURE_AUTO:return Auto 

[PATCH 03/15] [RFCv2] Documentation: add v4l2-controls.txt documenting the new controls API.

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
Reviewed-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/video4linux/v4l2-controls.txt |  600 +++
 1 files changed, 600 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/video4linux/v4l2-controls.txt

diff --git a/Documentation/video4linux/v4l2-controls.txt 
b/Documentation/video4linux/v4l2-controls.txt
new file mode 100644
index 000..44246b2
--- /dev/null
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -0,0 +1,600 @@
+Introduction
+
+
+The V4L2 control API seems simple enough, but quickly becomes very hard to
+implement correctly in drivers. But much of the code needed to handle controls
+is actually not driver specific and can be moved to the V4L core framework.
+
+After all, the only part that a driver developer is interested in is:
+
+1) How do I add a control?
+2) How do I set the control's value? (i.e. s_ctrl)
+
+And occasionally:
+
+3) How do I get the control's value? (i.e. g_volatile_ctrl)
+4) How do I validate the user's proposed control value? (i.e. try_ctrl)
+
+All the rest is something that can be done centrally.
+
+The control framework was created in order to implement all the rules of the
+V4L2 specification with respect to controls in a central place. And to make
+life as easy as possible for the driver developer.
+
+Note that the control framework relies on the presence of a struct v4l2_device
+for bridge drivers and struct v4l2_subdev for sub-device drivers.
+
+
+Objects in the framework
+
+
+There are two main objects:
+
+The v4l2_ctrl object describes the control properties and keeps track of the
+control's value (both the current value and the proposed new value).
+
+v4l2_ctrl_handler is the object that keeps track of controls. It maintains a
+list of v4l2_ctrl objects that it owns and another list of references to
+controls, possibly to controls owned by other handlers.
+
+
+Basic usage for bridge and sub-device drivers
+=
+
+1) Prepare the driver:
+
+1.1) Add the handler to your driver's top-level struct:
+
+   struct foo_dev {
+   ...
+   struct v4l2_ctrl_handler ctrl_handler;
+   ...
+   };
+
+   struct foo_dev *foo;
+
+1.2) Initialize the handler:
+
+   v4l2_ctrl_handler_init(foo-ctrl_handler, nr_of_controls);
+
+  The second argument is a hint telling the function how many controls this
+  handler is expected to handle. It will allocate a hashtable based on this
+  information. It is a hint only.
+
+1.3) Hook the control handler into the driver:
+
+1.3.1) For bridge drivers do this:
+
+   foo-v4l2_dev.ctrl_handler = foo-ctrl_handler;
+
+  Where foo-v4l2_dev is of type struct v4l2_device.
+
+  Finally, remove all control functions from your v4l2_ioctl_ops:
+  vidioc_queryctrl, vidioc_querymenu, vidioc_g_ctrl, vidioc_s_ctrl,
+  vidioc_g_ext_ctrls, vidioc_try_ext_ctrls and vidioc_s_ext_ctrls.
+  Those are now no longer needed.
+
+1.3.2) For sub-device drivers do this:
+
+   foo-sd.ctrl_handler = foo-ctrl_handler;
+
+  Where foo-sd is of type struct v4l2_subdev.
+
+  And set all core control ops in your struct v4l2_subdev_core_ops to these
+  helpers:
+
+   .queryctrl = v4l2_subdev_queryctrl,
+   .querymenu = v4l2_subdev_querymenu,
+   .g_ctrl = v4l2_subdev_g_ctrl,
+   .s_ctrl = v4l2_subdev_s_ctrl,
+   .g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
+   .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
+   .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
+
+  Note: this is a temporary solution only. Once everything is converted to
+  the control framework these helpers will no longer be needed.
+
+1.4) Clean up the handler at the end:
+
+   v4l2_ctrl_handler_free(foo-ctrl_handler);
+
+
+2) Add controls:
+
+Typically done right after the v4l2_ctrl_handler_init:
+
+   v4l2_ctrl_handler_init(foo-ctrl_handler, nr_of_controls);
+   v4l2_ctrl_new_std(foo-ctrl_handler, foo_ctrl_ops,
+   V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
+   v4l2_ctrl_new_std(foo-ctrl_handler, foo_ctrl_ops,
+   V4L2_CID_CONTRAST, 0, 255, 1, 128);
+   ...
+   if (foo-ctrl_handler.error) {
+   int err = foo-ctrl_handler.error;
+
+   v4l2_ctrl_handler_free(foo-ctrl_handler);
+   return err;
+   }
+
+The v4l2_ctrl_new_std function returns the v4l2_ctrl pointer to the new
+control, but if you do not need to access the pointer outside the control ops,
+then there is no need to store it.
+
+The v4l2_ctrl_new_std function will fill in most fields based on the control
+ID except for the min, max, step and default values. These are passed in the
+last four arguments. These values are driver specific while control attributes
+like type, name, flags are all global. The control's current value will be set
+to the default value.
+
+Note that if something fails, the 

[PATCH 04/15] [RFCv2] v4l2: hook up the new control framework into the core framework

2010-05-16 Thread Hans Verkuil
Add the calls needed to automatically merge subdev controls into a bridge
control handler.

Hook up the control framework in __video_ioctl2 and video_register_device.

Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/v4l2-dev.c|8 +-
 drivers/media/video/v4l2-device.c |7 +
 drivers/media/video/v4l2-ioctl.c  |   46 ++--
 3 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 0ca7ec9..773ffe1 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -447,8 +447,12 @@ static int __video_register_device(struct video_device 
*vdev, int type, int nr,
 
vdev-vfl_type = type;
vdev-cdev = NULL;
-   if (vdev-v4l2_dev  vdev-v4l2_dev-dev)
-   vdev-parent = vdev-v4l2_dev-dev;
+   if (vdev-v4l2_dev) {
+   if (vdev-v4l2_dev-dev)
+   vdev-parent = vdev-v4l2_dev-dev;
+   if (vdev-ctrl_handler == NULL)
+   vdev-ctrl_handler = vdev-v4l2_dev-ctrl_handler;
+   }
 
/* Part 2: find a free minor, device node number and device index. */
 #ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES
diff --git a/drivers/media/video/v4l2-device.c 
b/drivers/media/video/v4l2-device.c
index 5a7dc4a..0b08f96 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -26,6 +26,7 @@
 #endif
 #include linux/videodev2.h
 #include media/v4l2-device.h
+#include media/v4l2-ctrls.h
 
 int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
 {
@@ -115,6 +116,8 @@ EXPORT_SYMBOL_GPL(v4l2_device_unregister);
 int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
struct v4l2_subdev *sd)
 {
+   int err;
+
/* Check for valid input */
if (v4l2_dev == NULL || sd == NULL || !sd-name[0])
return -EINVAL;
@@ -122,6 +125,10 @@ int v4l2_device_register_subdev(struct v4l2_device 
*v4l2_dev,
WARN_ON(sd-v4l2_dev != NULL);
if (!try_module_get(sd-owner))
return -ENODEV;
+   /* This just returns 0 if either of the two args is NULL */
+   err = v4l2_ctrl_add_handler(v4l2_dev-ctrl_handler, sd-ctrl_handler);
+   if (err)
+   return err;
sd-v4l2_dev = v4l2_dev;
spin_lock(v4l2_dev-lock);
list_add_tail(sd-list, v4l2_dev-subdevs);
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 0395b1c..94776c3 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -25,6 +25,7 @@
 #endif
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-fh.h
 #include media/v4l2-event.h
 #include media/v4l2-chip-ident.h
@@ -1258,9 +1259,12 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_queryctrl *p = arg;
 
-   if (!ops-vidioc_queryctrl)
+   if (vfd-ctrl_handler)
+   ret = v4l2_queryctrl(vfd-ctrl_handler, p);
+   else if (ops-vidioc_queryctrl)
+   ret = ops-vidioc_queryctrl(file, fh, p);
+   else
break;
-   ret = ops-vidioc_queryctrl(file, fh, p);
if (!ret)
dbgarg(cmd, id=0x%x, type=%d, name=%s, min/max=%d/%d, 
step=%d, default=%d, flags=0x%08x\n,
@@ -1275,7 +1279,9 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_control *p = arg;
 
-   if (ops-vidioc_g_ctrl)
+   if (vfd-ctrl_handler)
+   ret = v4l2_g_ctrl(vfd-ctrl_handler, p);
+   else if (ops-vidioc_g_ctrl)
ret = ops-vidioc_g_ctrl(file, fh, p);
else if (ops-vidioc_g_ext_ctrls) {
struct v4l2_ext_controls ctrls;
@@ -1305,11 +1311,16 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_ext_controls ctrls;
struct v4l2_ext_control ctrl;
 
-   if (!ops-vidioc_s_ctrl  !ops-vidioc_s_ext_ctrls)
+   if (!vfd-ctrl_handler 
+   !ops-vidioc_s_ctrl  !ops-vidioc_s_ext_ctrls)
break;
 
dbgarg(cmd, id=0x%x, value=%d\n, p-id, p-value);
 
+   if (vfd-ctrl_handler) {
+   ret = v4l2_s_ctrl(vfd-ctrl_handler, p);
+   break;
+   }
if (ops-vidioc_s_ctrl) {
ret = ops-vidioc_s_ctrl(file, fh, p);
break;
@@ -1331,10 +1342,12 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_ext_controls *p = arg;
 
p-error_idx = p-count;
-   if (!ops-vidioc_g_ext_ctrls)
- 

[PATCH 05/15] [RFCv2] saa7115: convert to the new control framework

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/saa7115.c |  180 ++---
 1 files changed, 80 insertions(+), 100 deletions(-)

diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 53b6fcd..4f97c3e 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -45,6 +45,7 @@
 #include linux/i2c.h
 #include linux/videodev2.h
 #include media/v4l2-device.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-chip-ident.h
 #include media/v4l2-i2c-drv.h
 #include media/saa7115.h
@@ -65,16 +66,17 @@ MODULE_PARM_DESC(debug, Debug level (0-1));
 
 struct saa711x_state {
struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+
+   /* chroma gain control cluster */
+   struct v4l2_ctrl *agc;
+   struct v4l2_ctrl *gain;
+
v4l2_std_id std;
int input;
int output;
int enable;
int radio;
-   int bright;
-   int contrast;
-   int hue;
-   int sat;
-   int chroma_agc;
int width;
int height;
u32 ident;
@@ -90,6 +92,11 @@ static inline struct saa711x_state *to_state(struct 
v4l2_subdev *sd)
return container_of(sd, struct saa711x_state, sd);
 }
 
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl-handler, struct saa711x_state, hdl)-sd;
+}
+
 /* --- */
 
 static inline int saa711x_write(struct v4l2_subdev *sd, u8 reg, u8 value)
@@ -741,96 +748,53 @@ static int saa711x_s_clock_freq(struct v4l2_subdev *sd, 
u32 freq)
return 0;
 }
 
-static int saa711x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int saa711x_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct saa711x_state *state = to_state(sd);
-   u8 val;
 
switch (ctrl-id) {
-   case V4L2_CID_BRIGHTNESS:
-   if (ctrl-value  0 || ctrl-value  255) {
-   v4l2_err(sd, invalid brightness setting %d\n, 
ctrl-value);
-   return -ERANGE;
-   }
-
-   state-bright = ctrl-value;
-   saa711x_write(sd, R_0A_LUMA_BRIGHT_CNTL, state-bright);
-   break;
-
-   case V4L2_CID_CONTRAST:
-   if (ctrl-value  0 || ctrl-value  127) {
-   v4l2_err(sd, invalid contrast setting %d\n, 
ctrl-value);
-   return -ERANGE;
-   }
-
-   state-contrast = ctrl-value;
-   saa711x_write(sd, R_0B_LUMA_CONTRAST_CNTL, state-contrast);
-   break;
-
-   case V4L2_CID_SATURATION:
-   if (ctrl-value  0 || ctrl-value  127) {
-   v4l2_err(sd, invalid saturation setting %d\n, 
ctrl-value);
-   return -ERANGE;
-   }
-
-   state-sat = ctrl-value;
-   saa711x_write(sd, R_0C_CHROMA_SAT_CNTL, state-sat);
-   break;
-
-   case V4L2_CID_HUE:
-   if (ctrl-value  -128 || ctrl-value  127) {
-   v4l2_err(sd, invalid hue setting %d\n, ctrl-value);
-   return -ERANGE;
-   }
-
-   state-hue = ctrl-value;
-   saa711x_write(sd, R_0D_CHROMA_HUE_CNTL, state-hue);
-   break;
case V4L2_CID_CHROMA_AGC:
-   val = saa711x_read(sd, R_0F_CHROMA_GAIN_CNTL);
-   state-chroma_agc = ctrl-value;
-   if (ctrl-value)
-   val = 0x7f;
-   else
-   val |= 0x80;
-   saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, val);
+   /* chroma gain cluster */
+   if (state-agc-cur.val)
+   state-gain-cur.val =
+   saa711x_read(sd, R_0F_CHROMA_GAIN_CNTL)  0x7f;
break;
-   case V4L2_CID_CHROMA_GAIN:
-   /* Chroma gain cannot be set when AGC is enabled */
-   if (state-chroma_agc == 1)
-   return -EINVAL;
-   saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, ctrl-value | 0x80);
-   break;
-   default:
-   return -EINVAL;
}
-
return 0;
 }
 
-static int saa711x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int saa711x_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct saa711x_state *state = to_state(sd);
 
switch (ctrl-id) {
case V4L2_CID_BRIGHTNESS:
-   ctrl-value = state-bright;
+   saa711x_write(sd, R_0A_LUMA_BRIGHT_CNTL, ctrl-val);
break;
+
case V4L2_CID_CONTRAST:
-   ctrl-value = state-contrast;
+   saa711x_write(sd, R_0B_LUMA_CONTRAST_CNTL, ctrl-val);
break;
+
case V4L2_CID_SATURATION:
-  

[PATCH 06/15] [RFCv2] msp3400: convert to the new control framework

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/msp3400-driver.c   |  248 +++
 drivers/media/video/msp3400-driver.h   |   16 ++-
 drivers/media/video/msp3400-kthreads.c |   16 +-
 3 files changed, 108 insertions(+), 172 deletions(-)

diff --git a/drivers/media/video/msp3400-driver.c 
b/drivers/media/video/msp3400-driver.c
index e9df3cb..0e41213 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -283,51 +283,6 @@ void msp_set_scart(struct i2c_client *client, int in, int 
out)
msp_write_dem(client, 0x40, state-i2s_mode);
 }
 
-void msp_set_audio(struct i2c_client *client)
-{
-   struct msp_state *state = to_state(i2c_get_clientdata(client));
-   int bal = 0, bass, treble, loudness;
-   int val = 0;
-   int reallymuted = state-muted | state-scan_in_progress;
-
-   if (!reallymuted)
-   val = (state-volume * 0x7f / 65535)  8;
-
-   v4l_dbg(1, msp_debug, client, mute=%s scanning=%s volume=%d\n,
-   state-muted ? on : off,
-   state-scan_in_progress ? yes : no,
-   state-volume);
-
-   msp_write_dsp(client, 0x, val);
-   msp_write_dsp(client, 0x0007, reallymuted ? 0x1 : (val | 0x1));
-   if (state-has_scart2_out_volume)
-   msp_write_dsp(client, 0x0040, reallymuted ? 0x1 : (val | 0x1));
-   if (state-has_headphones)
-   msp_write_dsp(client, 0x0006, val);
-   if (!state-has_sound_processing)
-   return;
-
-   if (val)
-   bal = (u8)((state-balance / 256) - 128);
-   bass = ((state-bass - 32768) * 0x60 / 65535)  8;
-   treble = ((state-treble - 32768) * 0x60 / 65535)  8;
-   loudness = state-loudness ? ((5 * 4)  8) : 0;
-
-   v4l_dbg(1, msp_debug, client, balance=%d bass=%d treble=%d 
loudness=%d\n,
-   state-balance, state-bass, state-treble, state-loudness);
-
-   msp_write_dsp(client, 0x0001, bal  8);
-   msp_write_dsp(client, 0x0002, bass);
-   msp_write_dsp(client, 0x0003, treble);
-   msp_write_dsp(client, 0x0004, loudness);
-   if (!state-has_headphones)
-   return;
-   msp_write_dsp(client, 0x0030, bal  8);
-   msp_write_dsp(client, 0x0031, bass);
-   msp_write_dsp(client, 0x0032, treble);
-   msp_write_dsp(client, 0x0033, loudness);
-}
-
 /*  */
 
 static void msp_wake_thread(struct i2c_client *client)
@@ -363,98 +318,73 @@ int msp_sleep(struct msp_state *state, int timeout)
 
 /*  */
 
-static int msp_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int msp_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   struct msp_state *state = to_state(sd);
+   struct msp_state *state = ctrl_to_state(ctrl);
+   struct i2c_client *client = v4l2_get_subdevdata(state-sd);
+   int val = ctrl-val;
 
switch (ctrl-id) {
-   case V4L2_CID_AUDIO_VOLUME:
-   ctrl-value = state-volume;
-   break;
-
-   case V4L2_CID_AUDIO_MUTE:
-   ctrl-value = state-muted;
-   break;
-
-   case V4L2_CID_AUDIO_BALANCE:
-   if (!state-has_sound_processing)
-   return -EINVAL;
-   ctrl-value = state-balance;
-   break;
-
-   case V4L2_CID_AUDIO_BASS:
-   if (!state-has_sound_processing)
-   return -EINVAL;
-   ctrl-value = state-bass;
+   case V4L2_CID_AUDIO_VOLUME: {
+   /* audio volume cluster */
+   int reallymuted = state-muted-val | state-scan_in_progress;
+
+   if (!reallymuted)
+   val = (val * 0x7f / 65535)  8;
+
+   v4l_dbg(1, msp_debug, client, mute=%s scanning=%s volume=%d\n,
+   state-muted-val ? on : off,
+   state-scan_in_progress ? yes : no,
+   state-volume-val);
+
+   msp_write_dsp(client, 0x, val);
+   msp_write_dsp(client, 0x0007, reallymuted ? 0x1 : (val | 0x1));
+   if (state-has_scart2_out_volume)
+   msp_write_dsp(client, 0x0040, reallymuted ? 0x1 : (val 
| 0x1));
+   if (state-has_headphones)
+   msp_write_dsp(client, 0x0006, val);
break;
-
-   case V4L2_CID_AUDIO_TREBLE:
-   if (!state-has_sound_processing)
-   return -EINVAL;
-   ctrl-value = state-treble;
-   break;
-
-   case V4L2_CID_AUDIO_LOUDNESS:
-   if (!state-has_sound_processing)
-   return -EINVAL;
-   ctrl-value = state-loudness;
-   break;
-
-   default:
-   return -EINVAL;
}
-   return 0;

[PATCH 07/15] [RFCv2] saa717x: convert to the new control framework

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/saa717x.c |  323 ++--
 1 files changed, 81 insertions(+), 242 deletions(-)

diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c
index 6818df5..d551411 100644
--- a/drivers/media/video/saa717x.c
+++ b/drivers/media/video/saa717x.c
@@ -37,6 +37,7 @@
 #include linux/videodev2.h
 #include linux/i2c.h
 #include media/v4l2-device.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-i2c-drv.h
 
 MODULE_DESCRIPTION(Philips SAA717x audio/video decoder driver);
@@ -54,14 +55,11 @@ MODULE_PARM_DESC(debug, Debug level (0-1));
 
 struct saa717x_state {
struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
v4l2_std_id std;
int input;
int enable;
int radio;
-   int bright;
-   int contrast;
-   int hue;
-   int sat;
int playback;
int audio;
int tuner_audio_mode;
@@ -80,6 +78,11 @@ static inline struct saa717x_state *to_state(struct 
v4l2_subdev *sd)
return container_of(sd, struct saa717x_state, sd);
 }
 
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl-handler, struct saa717x_state, hdl)-sd;
+}
+
 /* --- */
 
 /* for audio mode */
@@ -773,29 +776,6 @@ static void set_audio_mode(struct v4l2_subdev *sd, int 
audio_mode)
saa717x_write(sd, 0x470, reg_set_audio_template[audio_mode][1]);
 }
 
-/* write regs to video output level (bright,contrast,hue,sat) */
-static void set_video_output_level_regs(struct v4l2_subdev *sd,
-   struct saa717x_state *decoder)
-{
-   /* brightness ffh (bright) - 80h (ITU level) - 00h (dark) */
-   saa717x_write(sd, 0x10a, decoder-bright);
-
-   /* contrast 7fh (max: 1.984) - 44h (ITU) - 40h (1.0) -
-  0h (luminance off) 40: i2c dump
-  c0h (-1.0 inverse chrominance)
-  80h (-2.0 inverse chrominance) */
-   saa717x_write(sd, 0x10b, decoder-contrast);
-
-   /* saturation? 7fh(max)-40h(ITU)-0h(color off)
-  c0h (-1.0 inverse chrominance)
-  80h (-2.0 inverse chrominance) */
-   saa717x_write(sd, 0x10c, decoder-sat);
-
-   /* color hue (phase) control
-  7fh (+178.6) - 0h (0 normal) - 80h (-180.0) */
-   saa717x_write(sd, 0x10d, decoder-hue);
-}
-
 /* write regs to set audio volume, bass and treble */
 static int set_audio_regs(struct v4l2_subdev *sd,
struct saa717x_state *decoder)
@@ -828,9 +808,9 @@ static int set_audio_regs(struct v4l2_subdev *sd,
 
saa717x_write(sd, 0x480, val);
 
-   /* bass and treble; go to another function */
/* set bass and treble */
-   val = decoder-audio_main_bass | (decoder-audio_main_treble  8);
+   val = decoder-audio_main_bass  0x1f;
+   val |= (decoder-audio_main_treble  0x1f)  5;
saa717x_write(sd, 0x488, val);
return 0;
 }
@@ -892,218 +872,55 @@ static void set_v_scale(struct v4l2_subdev *sd, int 
task, int yscale)
saa717x_write(sd, 0x71 + task_shift, yscale  8);
 }
 
-static int saa717x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct saa717x_state *state = to_state(sd);
-
-   switch (ctrl-id) {
-   case V4L2_CID_BRIGHTNESS:
-   if (ctrl-value  0 || ctrl-value  255) {
-   v4l2_err(sd, invalid brightness setting %d\n, 
ctrl-value);
-   return -ERANGE;
-   }
-
-   state-bright = ctrl-value;
-   v4l2_dbg(1, debug, sd, bright:%d\n, state-bright);
-   saa717x_write(sd, 0x10a, state-bright);
-   break;
-
-   case V4L2_CID_CONTRAST:
-   if (ctrl-value  0 || ctrl-value  127) {
-   v4l2_err(sd, invalid contrast setting %d\n, 
ctrl-value);
-   return -ERANGE;
-   }
-
-   state-contrast = ctrl-value;
-   v4l2_dbg(1, debug, sd, contrast:%d\n, state-contrast);
-   saa717x_write(sd, 0x10b, state-contrast);
-   break;
-
-   case V4L2_CID_SATURATION:
-   if (ctrl-value  0 || ctrl-value  127) {
-   v4l2_err(sd, invalid saturation setting %d\n, 
ctrl-value);
-   return -ERANGE;
-   }
-
-   state-sat = ctrl-value;
-   v4l2_dbg(1, debug, sd, sat:%d\n, state-sat);
-   saa717x_write(sd, 0x10c, state-sat);
-   break;
-
-   case V4L2_CID_HUE:
-   if (ctrl-value  -128 || ctrl-value  127) {
-   v4l2_err(sd, invalid hue setting %d\n, ctrl-value);
-   return -ERANGE;
-   }
-
-   state-hue = ctrl-value;
-   v4l2_dbg(1, debug, sd, hue:%d\n, state-hue);
-   saa717x_write(sd, 0x10d, state-hue);
-   break;

[PATCH 09/15] [RFCv2] cx25840: convert to the new control framework

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/cx25840/cx25840-audio.c |  144 +++---
 drivers/media/video/cx25840/cx25840-core.c  |  178 ++-
 drivers/media/video/cx25840/cx25840-core.h  |   15 ++-
 3 files changed, 91 insertions(+), 246 deletions(-)

diff --git a/drivers/media/video/cx25840/cx25840-audio.c 
b/drivers/media/video/cx25840/cx25840-audio.c
index 45608d5..6faad34 100644
--- a/drivers/media/video/cx25840/cx25840-audio.c
+++ b/drivers/media/video/cx25840/cx25840-audio.c
@@ -474,33 +474,10 @@ void cx25840_audio_set_path(struct i2c_client *client)
cx25840_and_or(client, 0x803, ~0x10, 0x10);
 }
 
-static int get_volume(struct i2c_client *client)
-{
-   struct cx25840_state *state = to_state(i2c_get_clientdata(client));
-   int vol;
-
-   if (state-unmute_volume = 0)
-   return state-unmute_volume;
-
-   /* Volume runs +18dB to -96dB in 1/2dB steps
-* change to fit the msp3400 -114dB to +12dB range */
-
-   /* check PATH1_VOLUME */
-   vol = 228 - cx25840_read(client, 0x8d4);
-   vol = (vol / 2) + 23;
-   return vol  9;
-}
-
 static void set_volume(struct i2c_client *client, int volume)
 {
-   struct cx25840_state *state = to_state(i2c_get_clientdata(client));
int vol;
 
-   if (state-unmute_volume = 0) {
-   state-unmute_volume = volume;
-   return;
-   }
-
/* Convert the volume to msp3400 values (0-127) */
vol = volume  9;
 
@@ -517,52 +494,6 @@ static void set_volume(struct i2c_client *client, int 
volume)
cx25840_write(client, 0x8d4, 228 - (vol * 2));
 }
 
-static int get_bass(struct i2c_client *client)
-{
-   /* bass is 49 steps +12dB to -12dB */
-
-   /* check PATH1_EQ_BASS_VOL */
-   int bass = cx25840_read(client, 0x8d9)  0x3f;
-   bass = (((48 - bass) * 0x) + 47) / 48;
-   return bass;
-}
-
-static void set_bass(struct i2c_client *client, int bass)
-{
-   /* PATH1_EQ_BASS_VOL */
-   cx25840_and_or(client, 0x8d9, ~0x3f, 48 - (bass * 48 / 0x));
-}
-
-static int get_treble(struct i2c_client *client)
-{
-   /* treble is 49 steps +12dB to -12dB */
-
-   /* check PATH1_EQ_TREBLE_VOL */
-   int treble = cx25840_read(client, 0x8db)  0x3f;
-   treble = (((48 - treble) * 0x) + 47) / 48;
-   return treble;
-}
-
-static void set_treble(struct i2c_client *client, int treble)
-{
-   /* PATH1_EQ_TREBLE_VOL */
-   cx25840_and_or(client, 0x8db, ~0x3f, 48 - (treble * 48 / 0x));
-}
-
-static int get_balance(struct i2c_client *client)
-{
-   /* balance is 7 bit, 0 to -96dB */
-
-   /* check PATH1_BAL_LEVEL */
-   int balance = cx25840_read(client, 0x8d5)  0x7f;
-   /* check PATH1_BAL_LEFT */
-   if ((cx25840_read(client, 0x8d5)  0x80) == 0)
-   balance = 0x80 - balance;
-   else
-   balance = 0x80 + balance;
-   return balance  8;
-}
-
 static void set_balance(struct i2c_client *client, int balance)
 {
int bal = balance  8;
@@ -579,31 +510,6 @@ static void set_balance(struct i2c_client *client, int 
balance)
}
 }
 
-static int get_mute(struct i2c_client *client)
-{
-   struct cx25840_state *state = to_state(i2c_get_clientdata(client));
-
-   return state-unmute_volume = 0;
-}
-
-static void set_mute(struct i2c_client *client, int mute)
-{
-   struct cx25840_state *state = to_state(i2c_get_clientdata(client));
-
-   if (mute  state-unmute_volume == -1) {
-   int vol = get_volume(client);
-
-   set_volume(client, 0);
-   state-unmute_volume = vol;
-   }
-   else if (!mute  state-unmute_volume != -1) {
-   int vol = state-unmute_volume;
-
-   state-unmute_volume = -1;
-   set_volume(client, vol);
-   }
-}
-
 int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -624,25 +530,31 @@ int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
return retval;
 }
 
-int cx25840_audio_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int cx25840_audio_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
+   struct cx25840_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
 
switch (ctrl-id) {
case V4L2_CID_AUDIO_VOLUME:
-   ctrl-value = get_volume(client);
+   if (state-mute-val)
+   set_volume(client, 0);
+   else
+   set_volume(client, state-volume-val);
break;
case V4L2_CID_AUDIO_BASS:
-   ctrl-value = get_bass(client);
+   /* PATH1_EQ_BASS_VOL */
+   cx25840_and_or(client, 0x8d9, ~0x3f,
+   48 - (ctrl-val * 48 / 0x));

[PATCH 10/15] [RFCv2] cx2341x: convert to the control framework

2010-05-16 Thread Hans Verkuil
Since this module is also used by drivers that are not yet converted, the old
and new code have to co-exist.

The source is split into three parts: a common part at the top, which is used
by both old and new code, then the old code followed by the new control
framework implementation. This new code is much more readable (and shorter!)
than the original code.

Once all bridge drivers that use this are converted the old code can be
deleted.

Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/cx2341x.c |  734 ++---
 include/media/cx2341x.h   |   81 +
 2 files changed, 703 insertions(+), 112 deletions(-)

diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c
index 022b480..ac2ebb5 100644
--- a/drivers/media/video/cx2341x.c
+++ b/drivers/media/video/cx2341x.c
@@ -38,6 +38,145 @@ static int debug;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, Debug level (0-1));
 
+/** COMMON CODE */
+
+/* definitions for audio properties bits 29-28 */
+#define CX2341X_AUDIO_ENCODING_METHOD_MPEG 0
+#define CX2341X_AUDIO_ENCODING_METHOD_AC3  1
+#define CX2341X_AUDIO_ENCODING_METHOD_LPCM 2
+
+static const char *cx2341x_get_name(u32 id)
+{
+   switch (id) {
+   case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE:
+   return Spatial Filter Mode;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER:
+   return Spatial Filter;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE:
+   return Spatial Luma Filter Type;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE:
+   return Spatial Chroma Filter Type;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE:
+   return Temporal Filter Mode;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER:
+   return Temporal Filter;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE:
+   return Median Filter Type;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP:
+   return Median Luma Filter Maximum;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM:
+   return Median Luma Filter Minimum;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP:
+   return Median Chroma Filter Maximum;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM:
+   return Median Chroma Filter Minimum;
+   case V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS:
+   return Insert Navigation Packets;
+   }
+   return NULL;
+}
+
+static const char **cx2341x_get_menu(u32 id)
+{
+   static const char *cx2341x_video_spatial_filter_mode_menu[] = {
+   Manual,
+   Auto,
+   NULL
+   };
+
+   static const char *cx2341x_video_luma_spatial_filter_type_menu[] = {
+   Off,
+   1D Horizontal,
+   1D Vertical,
+   2D H/V Separable,
+   2D Symmetric non-separable,
+   NULL
+   };
+
+   static const char *cx2341x_video_chroma_spatial_filter_type_menu[] = {
+   Off,
+   1D Horizontal,
+   NULL
+   };
+
+   static const char *cx2341x_video_temporal_filter_mode_menu[] = {
+   Manual,
+   Auto,
+   NULL
+   };
+
+   static const char *cx2341x_video_median_filter_type_menu[] = {
+   Off,
+   Horizontal,
+   Vertical,
+   Horizontal/Vertical,
+   Diagonal,
+   NULL
+   };
+
+   switch (id) {
+   case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE:
+   return cx2341x_video_spatial_filter_mode_menu;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE:
+   return cx2341x_video_luma_spatial_filter_type_menu;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE:
+   return cx2341x_video_chroma_spatial_filter_type_menu;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE:
+   return cx2341x_video_temporal_filter_mode_menu;
+   case V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE:
+   return cx2341x_video_median_filter_type_menu;
+   }
+   return NULL;
+}
+
+static void cx2341x_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type 
*type,
+   s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags)
+{
+   *name = cx2341x_get_name(id);
+   *flags = 0;
+
+   switch (id) {
+   case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE:
+   case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE:
+   case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE:
+   case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE:
+   case V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE:
+   

[PATCH 11/15] [RFCv2] wm8775: convert to the new control framework

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/wm8775.c |   79 ++---
 1 files changed, 50 insertions(+), 29 deletions(-)

diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index f1f261a..09a9663 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -34,6 +34,7 @@
 #include linux/videodev2.h
 #include media/v4l2-device.h
 #include media/v4l2-chip-ident.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-i2c-drv.h
 
 MODULE_DESCRIPTION(wm8775 driver);
@@ -52,8 +53,9 @@ enum {
 
 struct wm8775_state {
struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+   struct v4l2_ctrl *mute;
u8 input;   /* Last selected input (0-0xf) */
-   u8 muted;
 };
 
 static inline struct wm8775_state *to_state(struct v4l2_subdev *sd)
@@ -61,6 +63,11 @@ static inline struct wm8775_state *to_state(struct 
v4l2_subdev *sd)
return container_of(sd, struct wm8775_state, sd);
 }
 
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl-handler, struct wm8775_state, hdl)-sd;
+}
+
 static int wm8775_write(struct v4l2_subdev *sd, int reg, u16 val)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -94,7 +101,7 @@ static int wm8775_s_routing(struct v4l2_subdev *sd,
return -EINVAL;
}
state-input = input;
-   if (state-muted)
+   if (!v4l2_ctrl_g_ctrl(state-mute))
return 0;
wm8775_write(sd, R21, 0x0c0);
wm8775_write(sd, R14, 0x1d4);
@@ -103,29 +110,21 @@ static int wm8775_s_routing(struct v4l2_subdev *sd,
return 0;
 }
 
-static int wm8775_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int wm8775_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct wm8775_state *state = to_state(sd);
 
-   if (ctrl-id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   ctrl-value = state-muted;
-   return 0;
-}
-
-static int wm8775_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct wm8775_state *state = to_state(sd);
-
-   if (ctrl-id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   state-muted = ctrl-value;
-   wm8775_write(sd, R21, 0x0c0);
-   wm8775_write(sd, R14, 0x1d4);
-   wm8775_write(sd, R15, 0x1d4);
-   if (!state-muted)
-   wm8775_write(sd, R21, 0x100 + state-input);
-   return 0;
+   switch (ctrl-id) {
+   case V4L2_CID_AUDIO_MUTE:
+   wm8775_write(sd, R21, 0x0c0);
+   wm8775_write(sd, R14, 0x1d4);
+   wm8775_write(sd, R15, 0x1d4);
+   if (!ctrl-val)
+   wm8775_write(sd, R21, 0x100 + state-input);
+   return 0;
+   }
+   return -EINVAL;
 }
 
 static int wm8775_g_chip_ident(struct v4l2_subdev *sd, struct 
v4l2_dbg_chip_ident *chip)
@@ -139,8 +138,8 @@ static int wm8775_log_status(struct v4l2_subdev *sd)
 {
struct wm8775_state *state = to_state(sd);
 
-   v4l2_info(sd, Input: %d%s\n, state-input,
-   state-muted ?  (muted) : );
+   v4l2_info(sd, Input: %d\n, state-input);
+   v4l2_ctrl_handler_log_status(state-hdl, sd-name);
return 0;
 }
 
@@ -161,11 +160,20 @@ static int wm8775_s_frequency(struct v4l2_subdev *sd, 
struct v4l2_frequency *fre
 
 /* --- */
 
+static const struct v4l2_ctrl_ops wm8775_ctrl_ops = {
+   .s_ctrl = wm8775_s_ctrl,
+};
+
 static const struct v4l2_subdev_core_ops wm8775_core_ops = {
.log_status = wm8775_log_status,
.g_chip_ident = wm8775_g_chip_ident,
-   .g_ctrl = wm8775_g_ctrl,
-   .s_ctrl = wm8775_s_ctrl,
+   .g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
+   .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
+   .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
+   .g_ctrl = v4l2_subdev_g_ctrl,
+   .s_ctrl = v4l2_subdev_s_ctrl,
+   .queryctrl = v4l2_subdev_queryctrl,
+   .querymenu = v4l2_subdev_querymenu,
 };
 
 static const struct v4l2_subdev_tuner_ops wm8775_tuner_ops = {
@@ -204,13 +212,24 @@ static int wm8775_probe(struct i2c_client *client,
v4l_info(client, chip found @ 0x%02x (%s)\n,
client-addr  1, client-adapter-name);
 
-   state = kmalloc(sizeof(struct wm8775_state), GFP_KERNEL);
+   state = kzalloc(sizeof(struct wm8775_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
sd = state-sd;
v4l2_i2c_subdev_init(sd, client, wm8775_ops);
state-input = 2;
-   state-muted = 0;
+
+   v4l2_ctrl_handler_init(state-hdl, 1);
+   state-mute = v4l2_ctrl_new_std(state-hdl, wm8775_ctrl_ops,
+   V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
+   sd-ctrl_handler = state-hdl;
+   if (state-hdl.error) {
+   int err 

[PATCH 12/15] [RFCv2] cs53l32a: convert to new control framework.

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/cs53l32a.c |  107 +--
 1 files changed, 68 insertions(+), 39 deletions(-)

diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index 80bca8d..a46b1d0 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -25,10 +25,10 @@
 #include linux/ioctl.h
 #include asm/uaccess.h
 #include linux/i2c.h
-#include linux/i2c-id.h
 #include linux/videodev2.h
 #include media/v4l2-device.h
 #include media/v4l2-chip-ident.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-i2c-drv.h
 
 MODULE_DESCRIPTION(i2c device driver for cs53l32a Audio ADC);
@@ -42,6 +42,21 @@ module_param(debug, bool, 0644);
 MODULE_PARM_DESC(debug, Debugging messages, 0=Off (default), 1=On);
 
 
+struct cs53l32a_state {
+   struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+};
+
+static inline struct cs53l32a_state *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct cs53l32a_state, sd);
+}
+
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl-handler, struct cs53l32a_state, hdl)-sd;
+}
+
 /* --- */
 
 static int cs53l32a_write(struct v4l2_subdev *sd, u8 reg, u8 value)
@@ -73,31 +88,20 @@ static int cs53l32a_s_routing(struct v4l2_subdev *sd,
return 0;
 }
 
-static int cs53l32a_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int cs53l32a_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   if (ctrl-id == V4L2_CID_AUDIO_MUTE) {
-   ctrl-value = (cs53l32a_read(sd, 0x03)  0xc0) != 0;
-   return 0;
-   }
-   if (ctrl-id != V4L2_CID_AUDIO_VOLUME)
-   return -EINVAL;
-   ctrl-value = (s8)cs53l32a_read(sd, 0x04);
-   return 0;
-}
+   struct v4l2_subdev *sd = to_sd(ctrl);
 
-static int cs53l32a_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   if (ctrl-id == V4L2_CID_AUDIO_MUTE) {
-   cs53l32a_write(sd, 0x03, ctrl-value ? 0xf0 : 0x30);
+   switch (ctrl-id) {
+   case V4L2_CID_AUDIO_MUTE:
+   cs53l32a_write(sd, 0x03, ctrl-val ? 0xf0 : 0x30);
+   return 0;
+   case V4L2_CID_AUDIO_VOLUME:
+   cs53l32a_write(sd, 0x04, (u8)ctrl-val);
+   cs53l32a_write(sd, 0x05, (u8)ctrl-val);
return 0;
}
-   if (ctrl-id != V4L2_CID_AUDIO_VOLUME)
-   return -EINVAL;
-   if (ctrl-value  12 || ctrl-value  -96)
-   return -EINVAL;
-   cs53l32a_write(sd, 0x04, (u8) ctrl-value);
-   cs53l32a_write(sd, 0x05, (u8) ctrl-value);
-   return 0;
+   return -EINVAL;
 }
 
 static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, struct 
v4l2_dbg_chip_ident *chip)
@@ -110,23 +114,30 @@ static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, 
struct v4l2_dbg_chip_id
 
 static int cs53l32a_log_status(struct v4l2_subdev *sd)
 {
+   struct cs53l32a_state *state = to_state(sd);
u8 v = cs53l32a_read(sd, 0x01);
-   u8 m = cs53l32a_read(sd, 0x03);
-   s8 vol = cs53l32a_read(sd, 0x04);
 
-   v4l2_info(sd, Input:  %d%s\n, (v  4)  3,
-   (m  0xC0) ?  (muted) : );
-   v4l2_info(sd, Volume: %d dB\n, vol);
+   v4l2_info(sd, Input:  %d\n, (v  4)  3);
+   v4l2_ctrl_handler_log_status(state-hdl, sd-name);
return 0;
 }
 
 /* --- */
 
+static const struct v4l2_ctrl_ops cs53l32a_ctrl_ops = {
+   .s_ctrl = cs53l32a_s_ctrl,
+};
+
 static const struct v4l2_subdev_core_ops cs53l32a_core_ops = {
.log_status = cs53l32a_log_status,
.g_chip_ident = cs53l32a_g_chip_ident,
-   .g_ctrl = cs53l32a_g_ctrl,
-   .s_ctrl = cs53l32a_s_ctrl,
+   .g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
+   .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
+   .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
+   .g_ctrl = v4l2_subdev_g_ctrl,
+   .s_ctrl = v4l2_subdev_s_ctrl,
+   .queryctrl = v4l2_subdev_queryctrl,
+   .querymenu = v4l2_subdev_querymenu,
 };
 
 static const struct v4l2_subdev_audio_ops cs53l32a_audio_ops = {
@@ -150,6 +161,7 @@ static const struct v4l2_subdev_ops cs53l32a_ops = {
 static int cs53l32a_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
+   struct cs53l32a_state *state;
struct v4l2_subdev *sd;
int i;
 
@@ -163,9 +175,10 @@ static int cs53l32a_probe(struct i2c_client *client,
v4l_info(client, chip found @ 0x%x (%s)\n,
client-addr  1, client-adapter-name);
 
-   sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
-   if (sd == NULL)
+   state = kzalloc(sizeof(struct cs53l32a_state), GFP_KERNEL);
+   if (state == NULL)
return -ENOMEM;
+   sd = state-sd;

[PATCH 13/15] [RFCv2] wm8739: convert to the new control framework

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/wm8739.c |  176 ++
 1 files changed, 59 insertions(+), 117 deletions(-)

diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index b572ce2..af4e61f 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -26,11 +26,11 @@
 #include linux/ioctl.h
 #include asm/uaccess.h
 #include linux/i2c.h
-#include linux/i2c-id.h
 #include linux/videodev2.h
 #include media/v4l2-device.h
 #include media/v4l2-chip-ident.h
 #include media/v4l2-i2c-drv.h
+#include media/v4l2-ctrls.h
 
 MODULE_DESCRIPTION(wm8739 driver);
 MODULE_AUTHOR(T. Adachi, Hans Verkuil);
@@ -53,12 +53,11 @@ enum {
 
 struct wm8739_state {
struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+   struct v4l2_ctrl *volume;
+   struct v4l2_ctrl *mute;
+   struct v4l2_ctrl *balance;
u32 clock_freq;
-   u8 muted;
-   u16 volume;
-   u16 balance;
-   u8 vol_l;   /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
-   u8 vol_r;   /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
 };
 
 static inline struct wm8739_state *to_state(struct v4l2_subdev *sd)
@@ -66,6 +65,11 @@ static inline struct wm8739_state *to_state(struct 
v4l2_subdev *sd)
return container_of(sd, struct wm8739_state, sd);
 }
 
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl-handler, struct wm8739_state, hdl)-sd;
+}
+
 /*  */
 
 static int wm8739_write(struct v4l2_subdev *sd, int reg, u16 val)
@@ -88,58 +92,17 @@ static int wm8739_write(struct v4l2_subdev *sd, int reg, 
u16 val)
return -1;
 }
 
-/* write regs to set audio volume etc */
-static void wm8739_set_audio(struct v4l2_subdev *sd)
-{
-   struct wm8739_state *state = to_state(sd);
-   u16 mute = state-muted ? 0x80 : 0;
-
-   /* Volume setting: bits 0-4, 0x1f = 12 dB, 0x00 = -34.5 dB
-* Default setting: 0x17 = 0 dB
-*/
-   wm8739_write(sd, R0, (state-vol_l  0x1f) | mute);
-   wm8739_write(sd, R1, (state-vol_r  0x1f) | mute);
-}
-
-static int wm8739_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct wm8739_state *state = to_state(sd);
-
-   switch (ctrl-id) {
-   case V4L2_CID_AUDIO_MUTE:
-   ctrl-value = state-muted;
-   break;
-
-   case V4L2_CID_AUDIO_VOLUME:
-   ctrl-value = state-volume;
-   break;
-
-   case V4L2_CID_AUDIO_BALANCE:
-   ctrl-value = state-balance;
-   break;
-
-   default:
-   return -EINVAL;
-   }
-   return 0;
-}
-
-static int wm8739_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int wm8739_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct wm8739_state *state = to_state(sd);
unsigned int work_l, work_r;
+   u8 vol_l;   /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
+   u8 vol_r;   /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */
+   u16 mute;
 
switch (ctrl-id) {
-   case V4L2_CID_AUDIO_MUTE:
-   state-muted = ctrl-value;
-   break;
-
case V4L2_CID_AUDIO_VOLUME:
-   state-volume = ctrl-value;
-   break;
-
-   case V4L2_CID_AUDIO_BALANCE:
-   state-balance = ctrl-value;
break;
 
default:
@@ -147,52 +110,25 @@ static int wm8739_s_ctrl(struct v4l2_subdev *sd, struct 
v4l2_control *ctrl)
}
 
/* normalize ( 65535 to 0 - 31 to 0 (12dB to -34.5dB) ) */
-   work_l = (min(65536 - state-balance, 32768) * state-volume) / 32768;
-   work_r = (min(state-balance, (u16)32768) * state-volume) / 32768;
+   work_l = (min(65536 - state-balance-val, 32768) * state-volume-val) 
/ 32768;
+   work_r = (min(state-balance-val, 32768) * state-volume-val) / 32768;
 
-   state-vol_l = (long)work_l * 31 / 65535;
-   state-vol_r = (long)work_r * 31 / 65535;
+   vol_l = (long)work_l * 31 / 65535;
+   vol_r = (long)work_r * 31 / 65535;
 
/* set audio volume etc. */
-   wm8739_set_audio(sd);
+   mute = state-mute-val ? 0x80 : 0;
+
+   /* Volume setting: bits 0-4, 0x1f = 12 dB, 0x00 = -34.5 dB
+* Default setting: 0x17 = 0 dB
+*/
+   wm8739_write(sd, R0, (vol_l  0x1f) | mute);
+   wm8739_write(sd, R1, (vol_r  0x1f) | mute);
return 0;
 }
 
 /*  */
 
-static struct v4l2_queryctrl wm8739_qctrl[] = {
-   {
-   .id= V4L2_CID_AUDIO_VOLUME,
-   .name  = Volume,
-   .minimum   = 0,
-   .maximum   = 65535,
-   .step  = 65535/100,
-   

[PATCH 14/15] [RFCv2] ivtv: convert gpio subdev to new control framework.

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/ivtv/ivtv-driver.c |1 +
 drivers/media/video/ivtv/ivtv-driver.h |1 +
 drivers/media/video/ivtv/ivtv-gpio.c   |   77 +++-
 3 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/drivers/media/video/ivtv/ivtv-driver.c 
b/drivers/media/video/ivtv/ivtv-driver.c
index 85aab0e..1232d92 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -1370,6 +1370,7 @@ static void ivtv_remove(struct pci_dev *pdev)
printk(KERN_INFO ivtv: Removed %s\n, itv-card_name);
 
v4l2_device_unregister(itv-v4l2_dev);
+   v4l2_ctrl_handler_free(itv-hdl_gpio);
kfree(itv);
 }
 
diff --git a/drivers/media/video/ivtv/ivtv-driver.h 
b/drivers/media/video/ivtv/ivtv-driver.h
index 584c8e0..ba6c2fc 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -629,6 +629,7 @@ struct ivtv {
 
struct v4l2_device v4l2_dev;
struct v4l2_subdev sd_gpio; /* GPIO sub-device */
+   struct v4l2_ctrl_handler hdl_gpio;
u16 instance;
 
/* High-level state info */
diff --git a/drivers/media/video/ivtv/ivtv-gpio.c 
b/drivers/media/video/ivtv/ivtv-gpio.c
index aede061..8f0d077 100644
--- a/drivers/media/video/ivtv/ivtv-gpio.c
+++ b/drivers/media/video/ivtv/ivtv-gpio.c
@@ -24,6 +24,7 @@
 #include ivtv-gpio.h
 #include tuner-xc2028.h
 #include media/tuner.h
+#include media/v4l2-ctrls.h
 
 /*
  * GPIO assignment of Yuan MPG600/MPG160
@@ -149,16 +150,10 @@ static inline struct ivtv *sd_to_ivtv(struct v4l2_subdev 
*sd)
return container_of(sd, struct ivtv, sd_gpio);
 }
 
-static struct v4l2_queryctrl gpio_ctrl_mute = {
-   .id= V4L2_CID_AUDIO_MUTE,
-   .type  = V4L2_CTRL_TYPE_BOOLEAN,
-   .name  = Mute,
-   .minimum   = 0,
-   .maximum   = 1,
-   .step  = 1,
-   .default_value = 1,
-   .flags = 0,
-};
+static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl-handler, struct ivtv, hdl_gpio)-sd_gpio;
+}
 
 static int subdev_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
 {
@@ -262,40 +257,24 @@ static int subdev_s_audio_routing(struct v4l2_subdev *sd,
return 0;
 }
 
-static int subdev_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+static int subdev_s_ctrl(struct v4l2_ctrl *ctrl)
 {
+   struct v4l2_subdev *sd = to_sd(ctrl);
struct ivtv *itv = sd_to_ivtv(sd);
u16 mask, data;
 
-   if (ctrl-id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   mask = itv-card-gpio_audio_mute.mask;
-   data = itv-card-gpio_audio_mute.mute;
-   ctrl-value = (read_reg(IVTV_REG_GPIO_OUT)  mask) == data;
-   return 0;
-}
-
-static int subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
-{
-   struct ivtv *itv = sd_to_ivtv(sd);
-   u16 mask, data;
-
-   if (ctrl-id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   mask = itv-card-gpio_audio_mute.mask;
-   data = ctrl-value ? itv-card-gpio_audio_mute.mute : 0;
-   if (mask)
-   write_reg((read_reg(IVTV_REG_GPIO_OUT)  ~mask) | (data  
mask), IVTV_REG_GPIO_OUT);
-   return 0;
+   switch (ctrl-id) {
+   case V4L2_CID_AUDIO_MUTE:
+   mask = itv-card-gpio_audio_mute.mask;
+   data = ctrl-val ? itv-card-gpio_audio_mute.mute : 0;
+   if (mask)
+   write_reg((read_reg(IVTV_REG_GPIO_OUT)  ~mask) |
+   (data  mask), IVTV_REG_GPIO_OUT);
+   return 0;
+   }
+   return -EINVAL;
 }
 
-static int subdev_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
-{
-   if (qc-id != V4L2_CID_AUDIO_MUTE)
-   return -EINVAL;
-   *qc = gpio_ctrl_mute;
-   return 0;
-}
 
 static int subdev_log_status(struct v4l2_subdev *sd)
 {
@@ -304,6 +283,7 @@ static int subdev_log_status(struct v4l2_subdev *sd)
IVTV_INFO(GPIO status: DIR=0x%04x OUT=0x%04x IN=0x%04x\n,
read_reg(IVTV_REG_GPIO_DIR), 
read_reg(IVTV_REG_GPIO_OUT),
read_reg(IVTV_REG_GPIO_IN));
+   v4l2_ctrl_handler_log_status(itv-hdl_gpio, sd-name);
return 0;
 }
 
@@ -327,11 +307,19 @@ static int subdev_s_video_routing(struct v4l2_subdev *sd,
return 0;
 }
 
+static const struct v4l2_ctrl_ops gpio_ctrl_ops = {
+   .s_ctrl = subdev_s_ctrl,
+};
+
 static const struct v4l2_subdev_core_ops subdev_core_ops = {
.log_status = subdev_log_status,
-   .g_ctrl = subdev_g_ctrl,
-   .s_ctrl = subdev_s_ctrl,
-   .queryctrl = subdev_queryctrl,
+   .g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
+   .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
+   .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
+   .g_ctrl = v4l2_subdev_g_ctrl,
+   .s_ctrl = v4l2_subdev_s_ctrl,

[PATCH 15/15] [RFCv2] ivtv: convert to the new control framework

2010-05-16 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hverk...@xs4all.nl
---
 drivers/media/video/ivtv/ivtv-controls.c |  275 --
 drivers/media/video/ivtv/ivtv-controls.h |6 +-
 drivers/media/video/ivtv/ivtv-driver.c   |   18 ++-
 drivers/media/video/ivtv/ivtv-driver.h   |5 +-
 drivers/media/video/ivtv/ivtv-fileops.c  |   23 +--
 drivers/media/video/ivtv/ivtv-firmware.c |6 +-
 drivers/media/video/ivtv/ivtv-ioctl.c|   31 ++--
 drivers/media/video/ivtv/ivtv-streams.c  |   20 ++-
 8 files changed, 86 insertions(+), 298 deletions(-)

diff --git a/drivers/media/video/ivtv/ivtv-controls.c 
b/drivers/media/video/ivtv/ivtv-controls.c
index 4a9c8ce..57f74c2 100644
--- a/drivers/media/video/ivtv/ivtv-controls.c
+++ b/drivers/media/video/ivtv/ivtv-controls.c
@@ -17,162 +17,14 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#include linux/kernel.h
 
 #include ivtv-driver.h
-#include ivtv-cards.h
 #include ivtv-ioctl.h
-#include ivtv-routing.h
-#include ivtv-i2c.h
-#include ivtv-mailbox.h
 #include ivtv-controls.h
 
-/* Must be sorted from low to high control ID! */
-static const u32 user_ctrls[] = {
-   V4L2_CID_USER_CLASS,
-   V4L2_CID_BRIGHTNESS,
-   V4L2_CID_CONTRAST,
-   V4L2_CID_SATURATION,
-   V4L2_CID_HUE,
-   V4L2_CID_AUDIO_VOLUME,
-   V4L2_CID_AUDIO_BALANCE,
-   V4L2_CID_AUDIO_BASS,
-   V4L2_CID_AUDIO_TREBLE,
-   V4L2_CID_AUDIO_MUTE,
-   V4L2_CID_AUDIO_LOUDNESS,
-   0
-};
-
-static const u32 *ctrl_classes[] = {
-   user_ctrls,
-   cx2341x_mpeg_ctrls,
-   NULL
-};
-
-
-int ivtv_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qctrl)
-{
-   struct ivtv *itv = ((struct ivtv_open_id *)fh)-itv;
-   const char *name;
-
-   qctrl-id = v4l2_ctrl_next(ctrl_classes, qctrl-id);
-   if (qctrl-id == 0)
-   return -EINVAL;
-
-   switch (qctrl-id) {
-   /* Standard V4L2 controls */
-   case V4L2_CID_USER_CLASS:
-   return v4l2_ctrl_query_fill(qctrl, 0, 0, 0, 0);
-   case V4L2_CID_BRIGHTNESS:
-   case V4L2_CID_HUE:
-   case V4L2_CID_SATURATION:
-   case V4L2_CID_CONTRAST:
-   if (v4l2_subdev_call(itv-sd_video, core, queryctrl, qctrl))
-   qctrl-flags |= V4L2_CTRL_FLAG_DISABLED;
-   return 0;
-
-   case V4L2_CID_AUDIO_VOLUME:
-   case V4L2_CID_AUDIO_MUTE:
-   case V4L2_CID_AUDIO_BALANCE:
-   case V4L2_CID_AUDIO_BASS:
-   case V4L2_CID_AUDIO_TREBLE:
-   case V4L2_CID_AUDIO_LOUDNESS:
-   if (v4l2_subdev_call(itv-sd_audio, core, queryctrl, qctrl))
-   qctrl-flags |= V4L2_CTRL_FLAG_DISABLED;
-   return 0;
-
-   default:
-   if (cx2341x_ctrl_query(itv-params, qctrl))
-   qctrl-flags |= V4L2_CTRL_FLAG_DISABLED;
-   return 0;
-   }
-   strncpy(qctrl-name, name, sizeof(qctrl-name) - 1);
-   qctrl-name[sizeof(qctrl-name) - 1] = 0;
-   return 0;
-}
-
-int ivtv_querymenu(struct file *file, void *fh, struct v4l2_querymenu *qmenu)
-{
-   struct ivtv *itv = ((struct ivtv_open_id *)fh)-itv;
-   struct v4l2_queryctrl qctrl;
-
-   qctrl.id = qmenu-id;
-   ivtv_queryctrl(file, fh, qctrl);
-   return v4l2_ctrl_query_menu(qmenu, qctrl,
-   cx2341x_ctrl_get_menu(itv-params, qmenu-id));
-}
-
-static int ivtv_try_ctrl(struct file *file, void *fh,
-   struct v4l2_ext_control *vctrl)
-{
-   struct v4l2_queryctrl qctrl;
-   const char **menu_items = NULL;
-   int err;
-
-   qctrl.id = vctrl-id;
-   err = ivtv_queryctrl(file, fh, qctrl);
-   if (err)
-   return err;
-   if (qctrl.type == V4L2_CTRL_TYPE_MENU)
-   menu_items = v4l2_ctrl_get_menu(qctrl.id);
-   return v4l2_ctrl_check(vctrl, qctrl, menu_items);
-}
-
-static int ivtv_s_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
-{
-   switch (vctrl-id) {
-   /* Standard V4L2 controls */
-   case V4L2_CID_BRIGHTNESS:
-   case V4L2_CID_HUE:
-   case V4L2_CID_SATURATION:
-   case V4L2_CID_CONTRAST:
-   return v4l2_subdev_call(itv-sd_video, core, s_ctrl, vctrl);
-
-   case V4L2_CID_AUDIO_VOLUME:
-   case V4L2_CID_AUDIO_MUTE:
-   case V4L2_CID_AUDIO_BALANCE:
-   case V4L2_CID_AUDIO_BASS:
-   case V4L2_CID_AUDIO_TREBLE:
-   case V4L2_CID_AUDIO_LOUDNESS:
-   return v4l2_subdev_call(itv-sd_audio, core, s_ctrl, vctrl);
-
-   default:
-   IVTV_DEBUG_IOCTL(invalid control 0x%x\n, vctrl-id);
-   return -EINVAL;
-   }
-   return 0;
-}
-
-static int ivtv_g_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
+static int ivtv_s_stream_vbi_fmt(struct cx2341x_handler *cxhdl, u32 fmt)
 {
-   switch (vctrl-id) {
-   /* Standard 

Re: av7110 and budget_av are broken!

2010-05-16 Thread Oliver Endriss
On Sunday 16 May 2010 14:57:18 Mauro Carvalho Chehab wrote:
 Oliver Endriss wrote:
  On Sunday 16 May 2010 03:53:48 hermann pitton wrote:
  Hi, Douglas and Oliver,
 
  just as a small comment.
 
  I have not been on latest rc1 and such rcs close to a release for some
  time.
 
  But I was for a long time and v4l-dvb can't be a substitute for such.
  
  Sorry, I do not want to cope with experimental kernels and their bugs on
  my systems. I need a stable and reliable platform, so that I can
  concentrate on 'my' bugs.
  
  Usually I update the kernel every 3..4 releases (which causes enough
  trouble due to changed features, interfaces etc).
 
 I used to do it, but, in fact updating every release and following stable
 worked better for me, since there are less changes at the features, making
 easier to compile a new kernel that won't break anything.
 
 Anyway, it is up to you to use whatever works better for you.

Well, the problem is bug hunting: If you have changes both in the kernel
and in the driver, it is harder to identify the problem...

  Despite of getting more users for testing, on _that_ front does not
  happen such much currently, keeping v4l-dvb is mostly a service for
  developers this time.
 
  So, contributing on the backports and helping Douglas with such is
  really welcome.
  
  I confess that I do not know much about the tree handling procedures of
  the kernel. Imho it sounds crazy to have separate 'fixes' and
  'development' trees.
 
 I'll change the procedures for 2.6.35. I'll basically opt for having
 topic branches (for example, having a ngene branch), where all ngene patches
 will be applied, updating master only after having those patches in kernel.

How do you handle patches for shared components (frontend drivers,
dvb-core etc)? With topic branches, you have to apply those to every
topic branch which depends on them.

 I'll likely create a stable branch, with the latest kernel, plus all patches
 (like v2.6.34-v4l-dvb), to help people that want to develop using git.
 
 The big problem when handling patches upstream is caused by rebasing a patch,
 and the higher number of patches in a tree, the higher is the probability that
 a rebase will needed to avoid breaking compilation on a bisect.
 
 To give you an example, one big series of patches moved slab.h into each 
 driver that uses malloc. If a new driver or c file that needs this include
 on our series were added, to avoid breaking bisect, we need to go to the patch
 that introduced this code, and add the include there. All patches after this
 one needs to be rebased, when submitting upstream.

I would rather break bisect than doing that. In this example one could
simply disable the new driver in menuconfig to avoid the problem.

 So, let's say that the original patch has 05a43 has, and the new patch has
 a0342 (fictional numbers).
 
 So, in the development branches, this patch is known as 05a43, where, on
 upstream, this patch will be known as a0342.
 
 If I rebase the development tree, all developers using git would need to 
 rebase
 their trees. If I don't rebase, after merging from upstream, this patch will
 appear 2 times at the master branch history: as 05a43 and as a0342. To be 
 worse,
 on the next time I need to send patches upstream, this patch will appear again
 on my pile of patches to be submitted, and I'll need to manually drop it.
 Due to 2.6.33 merge, this problem is already present on our master branch. So,
 I'll need to drop a big pile of patches on my next upstream pull request.
 At each new kernel release, things would become worse.

Hm. Imho tree handling is getting way too complicated. ;-(

 With topic branches, things will hopefully become easier, as people can base 
 their
 trees on a topic branch. Also, we may have some topic branches based on a 
 stable
 release, and others based on upstream, but it will require me to maintain 
 separate
 development branches with all merging patches per kernel release.

See above. I doubt that it will make things really easier.

  A developer's tree (no matter whether HG or GIT) must also include the
  fixes, otherwise it is unusable. You cannot wait until applied fixes
  flow back from the kernel.
  
  Btw, the v4ldvb HG repositories contain tons of disabled code (marked
  '#if 0'), which was stripped for submission to the kernel.
  Even if we would switch to GIT completely, we need a separate GIT
  repository which would hold the original code.
 
 This is due to a policy we had at -hg time: not pollute upstream with
 dead code garbage. Maybe we may have a topic branch with all those dead code, 
 but I think that, before adding those code on kernel, we need to review what 
 will be added there: there are _lots_ of such #if 0 code that is there for 
 years and were never touched (in a matter of fact, this is the typical
 case). It seems valuable to do a cleanup first, at -hg, removing the ones that
 are there for ages and that nobody is interested on working it, and 

consumer marketing lists

2010-05-16 Thread relate
We have lists for healthcare, business  finance, consumers and professionals. 
Lots of different lists from various optin sources.

Just send me an email here for additional info: successto...@gmx.com

  


Send us an email to remfi...@gmx.com we will discontinue from the list
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] si4713: Fix oops when si4713_platform_data is marked as __initdata

2010-05-16 Thread Jarkko Nikula
This driver can cause an oops if si4713_platform_data holding pointer to
set_power function is marked as __initdata and when trying to power up the
chip after booting e.g. with 'v4l2-ctl -d /dev/radio0 --set-ctrl=mute=0'.

This happens because the sdev-platform_data doesn't point to valid data
anymore after kernel is initialized.

Fix this by taking local copy of si4713_platform_data-set_power. Add also
NULL check for this function pointer.

Signed-off-by: Jarkko Nikula jhnik...@gmail.com
Cc: Eduardo Valentin eduardo.valen...@nokia.com
---
 drivers/media/radio/si4713-i2c.c |   15 +--
 drivers/media/radio/si4713-i2c.h |2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/media/radio/si4713-i2c.c b/drivers/media/radio/si4713-i2c.c
index ab63dd5..cf9858d 100644
--- a/drivers/media/radio/si4713-i2c.c
+++ b/drivers/media/radio/si4713-i2c.c
@@ -369,7 +369,8 @@ static int si4713_powerup(struct si4713_device *sdev)
if (sdev-power_state)
return 0;
 
-   sdev-platform_data-set_power(1);
+   if (sdev-set_power)
+   sdev-set_power(1);
err = si4713_send_command(sdev, SI4713_CMD_POWER_UP,
args, ARRAY_SIZE(args),
resp, ARRAY_SIZE(resp),
@@ -383,8 +384,8 @@ static int si4713_powerup(struct si4713_device *sdev)
 
err = si4713_write_property(sdev, SI4713_GPO_IEN,
SI4713_STC_INT | SI4713_CTS);
-   } else {
-   sdev-platform_data-set_power(0);
+   } else if (sdev-set_power) {
+   sdev-set_power(0);
}
 
return err;
@@ -411,7 +412,8 @@ static int si4713_powerdown(struct si4713_device *sdev)
v4l2_dbg(1, debug, sdev-sd, Power down response: 0x%02x\n,
resp[0]);
v4l2_dbg(1, debug, sdev-sd, Device in reset mode\n);
-   sdev-platform_data-set_power(0);
+   if (sdev-set_power)
+   sdev-set_power(0);
sdev-power_state = POWER_OFF;
}
 
@@ -1959,6 +1961,7 @@ static int si4713_probe(struct i2c_client *client,
const struct i2c_device_id *id)
 {
struct si4713_device *sdev;
+   struct si4713_platform_data *pdata = client-dev.platform_data;
int rval;
 
sdev = kzalloc(sizeof *sdev, GFP_KERNEL);
@@ -1968,12 +1971,12 @@ static int si4713_probe(struct i2c_client *client,
goto exit;
}
 
-   sdev-platform_data = client-dev.platform_data;
-   if (!sdev-platform_data) {
+   if (!pdata) {
v4l2_err(sdev-sd, No platform data registered.\n);
rval = -ENODEV;
goto free_sdev;
}
+   sdev-set_power = pdata-set_power;
 
v4l2_i2c_subdev_init(sdev-sd, client, si4713_subdev_ops);
 
diff --git a/drivers/media/radio/si4713-i2c.h b/drivers/media/radio/si4713-i2c.h
index faf8cff..d1af889 100644
--- a/drivers/media/radio/si4713-i2c.h
+++ b/drivers/media/radio/si4713-i2c.h
@@ -220,7 +220,7 @@ struct si4713_device {
/* private data structures */
struct mutex mutex;
struct completion work;
-   struct si4713_platform_data *platform_data;
+   int (*set_power)(int power);
struct rds_info rds_info;
struct limiter_info limiter_info;
struct pilot_info pilot_info;
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: av7110 and budget_av are broken!

2010-05-16 Thread Mauro Carvalho Chehab
Oliver Endriss wrote:
 On Sunday 16 May 2010 14:57:18 Mauro Carvalho Chehab wrote:
 Oliver Endriss wrote:
 On Sunday 16 May 2010 03:53:48 hermann pitton wrote:
 Hi, Douglas and Oliver,

 just as a small comment.

 I have not been on latest rc1 and such rcs close to a release for some
 time.

 But I was for a long time and v4l-dvb can't be a substitute for such.
 Sorry, I do not want to cope with experimental kernels and their bugs on
 my systems. I need a stable and reliable platform, so that I can
 concentrate on 'my' bugs.

 Usually I update the kernel every 3..4 releases (which causes enough
 trouble due to changed features, interfaces etc).
 I used to do it, but, in fact updating every release and following stable
 worked better for me, since there are less changes at the features, making
 easier to compile a new kernel that won't break anything.

 Anyway, it is up to you to use whatever works better for you.
 
 Well, the problem is bug hunting: If you have changes both in the kernel
 and in the driver, it is harder to identify the problem...

True, but if you're using an older kernel version, you can miss some bugs that
appeared because of some changes that happened upstream.
 
 Despite of getting more users for testing, on _that_ front does not
 happen such much currently, keeping v4l-dvb is mostly a service for
 developers this time.

 So, contributing on the backports and helping Douglas with such is
 really welcome.
 I confess that I do not know much about the tree handling procedures of
 the kernel. Imho it sounds crazy to have separate 'fixes' and
 'development' trees.
 I'll change the procedures for 2.6.35. I'll basically opt for having
 topic branches (for example, having a ngene branch), where all ngene 
 patches
 will be applied, updating master only after having those patches in kernel.
 
 How do you handle patches for shared components (frontend drivers,
 dvb-core etc)? With topic branches, you have to apply those to every
 topic branch which depends on them.

Yes. x86 is using topic branches and it is working there. So, I'm expecting that
the same kind of procedure could work for us.

 I'll likely create a stable branch, with the latest kernel, plus all patches
 (like v2.6.34-v4l-dvb), to help people that want to develop using git.

 The big problem when handling patches upstream is caused by rebasing a patch,
 and the higher number of patches in a tree, the higher is the probability 
 that
 a rebase will needed to avoid breaking compilation on a bisect.

 To give you an example, one big series of patches moved slab.h into each 
 driver that uses malloc. If a new driver or c file that needs this include
 on our series were added, to avoid breaking bisect, we need to go to the 
 patch
 that introduced this code, and add the include there. All patches after this
 one needs to be rebased, when submitting upstream.
 
 I would rather break bisect than doing that. In this example one could
 simply disable the new driver in menuconfig to avoid the problem.

If it is a new driver, we can do that, but even moving a patch at the patch 
series
or changing an unrelated patch will change the md5sum for the entire series.

Disabling bisect hurts not only us, when seeking for a bug, but any other 
developer/user
that is seeking for what patch broke for him. From one kernel version to the 
next one,
dozens of thousands of patches are applied. With bisect, a broken patch can be 
identified
with about 10 compilations, while, without bisect, you'll need to seek the 
entire patch 
series.

So, it is not an option to break bisect.
 
 So, let's say that the original patch has 05a43 has, and the new patch has
 a0342 (fictional numbers).

 So, in the development branches, this patch is known as 05a43, where, on
 upstream, this patch will be known as a0342.

 If I rebase the development tree, all developers using git would need to 
 rebase
 their trees. If I don't rebase, after merging from upstream, this patch will
 appear 2 times at the master branch history: as 05a43 and as a0342. To be 
 worse,
 on the next time I need to send patches upstream, this patch will appear 
 again
 on my pile of patches to be submitted, and I'll need to manually drop it.
 Due to 2.6.33 merge, this problem is already present on our master branch. 
 So,
 I'll need to drop a big pile of patches on my next upstream pull request.
 At each new kernel release, things would become worse.
 
 Hm. Imho tree handling is getting way too complicated. ;-(

It were always complex, but as we're having much more conflicts with SoC 
patches, and
a much higher number of patches, the old process, where I was fixing the 
conflicts myself 
only when sending stuff upstream, weren't working anymore, as the number of 
troubles
were exponentially increasing with a linear grouth of the number of patches.

Anyway, I'm open to suggestions to improve the process.

 With topic branches, things will hopefully become easier, as people can base 
 their
 trees on a 

[cron job] v4l-dvb daily build 2.6.22 and up: ERRORS, 2.6.16-2.6.21: ERRORS

2010-05-16 Thread Hans Verkuil
This message is generated daily by a cron job that builds v4l-dvb for
the kernels and architectures in the list below.

Results of the daily build of v4l-dvb:

date:Sun May 16 19:00:20 CEST 2010
path:http://www.linuxtv.org/hg/v4l-dvb
changeset:   14857:2f5632eaf01d
git master:   f6760aa024199cfbce564311dc4bc4d47b6fb349
git media-master: 4fcfa8824391ef0f9cff82122067f31c6d920921
gcc version:  i686-linux-gcc (GCC) 4.4.3
host hardware:x86_64
host os:  2.6.32.5

linux-2.6.32.6-armv5: OK
linux-2.6.33-armv5: OK
linux-2.6.34-rc7-armv5: ERRORS
linux-2.6.32.6-armv5-davinci: OK
linux-2.6.33-armv5-davinci: OK
linux-2.6.34-rc7-armv5-davinci: ERRORS
linux-2.6.32.6-armv5-ixp: OK
linux-2.6.33-armv5-ixp: OK
linux-2.6.34-rc7-armv5-ixp: ERRORS
linux-2.6.32.6-armv5-omap2: OK
linux-2.6.33-armv5-omap2: OK
linux-2.6.34-rc7-armv5-omap2: ERRORS
linux-2.6.22.19-i686: ERRORS
linux-2.6.23.17-i686: ERRORS
linux-2.6.24.7-i686: ERRORS
linux-2.6.25.20-i686: ERRORS
linux-2.6.26.8-i686: ERRORS
linux-2.6.27.44-i686: ERRORS
linux-2.6.28.10-i686: ERRORS
linux-2.6.29.1-i686: ERRORS
linux-2.6.30.10-i686: WARNINGS
linux-2.6.31.12-i686: OK
linux-2.6.32.6-i686: OK
linux-2.6.33-i686: OK
linux-2.6.34-rc7-i686: ERRORS
linux-2.6.32.6-m32r: OK
linux-2.6.33-m32r: OK
linux-2.6.34-rc7-m32r: ERRORS
linux-2.6.32.6-mips: OK
linux-2.6.33-mips: OK
linux-2.6.34-rc7-mips: ERRORS
linux-2.6.32.6-powerpc64: OK
linux-2.6.33-powerpc64: OK
linux-2.6.34-rc7-powerpc64: ERRORS
linux-2.6.22.19-x86_64: ERRORS
linux-2.6.23.17-x86_64: ERRORS
linux-2.6.24.7-x86_64: ERRORS
linux-2.6.25.20-x86_64: ERRORS
linux-2.6.26.8-x86_64: ERRORS
linux-2.6.27.44-x86_64: ERRORS
linux-2.6.28.10-x86_64: ERRORS
linux-2.6.29.1-x86_64: ERRORS
linux-2.6.30.10-x86_64: WARNINGS
linux-2.6.31.12-x86_64: OK
linux-2.6.32.6-x86_64: OK
linux-2.6.33-x86_64: OK
linux-2.6.34-rc7-x86_64: ERRORS
linux-git-armv5: WARNINGS
linux-git-armv5-davinci: WARNINGS
linux-git-armv5-ixp: WARNINGS
linux-git-armv5-omap2: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-x86_64: WARNINGS
spec: ERRORS
spec-git: OK
sparse: ERRORS
linux-2.6.16.62-i686: ERRORS
linux-2.6.17.14-i686: ERRORS
linux-2.6.18.8-i686: ERRORS
linux-2.6.19.7-i686: ERRORS
linux-2.6.20.21-i686: ERRORS
linux-2.6.21.7-i686: ERRORS
linux-2.6.16.62-x86_64: ERRORS
linux-2.6.17.14-x86_64: ERRORS
linux-2.6.18.8-x86_64: ERRORS
linux-2.6.19.7-x86_64: ERRORS
linux-2.6.20.21-x86_64: ERRORS
linux-2.6.21.7-x86_64: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Sunday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Sunday.tar.bz2

The V4L-DVB specification from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PULL] http://linuxtv.org/hg/~mcisely/pvrusb2-patches

2010-05-16 Thread Mike Isely

Please from http://linuxtv.org/hg/~mcisely/pvrusb2-patches for the
following pvrusb2 driver fixes / improvements:

- pvrusb2: Minor debug code fixup
- pvrusb2: Fix Gotview hardware support
- pvrusb2: Avoid using stack allocated buffers when performing USB I/O
- pvrusb2: New feature to mark specific hardware support as experimental
- pvrusb2: Fix kernel oops at device unregistration
- pvrusb2: Fix missing header include
- pvrusb2: Fix USB parent device reference count
- pvrusb2: Fix minor internal array allocation
- pvrusb2: Fix kernel oops on device tear-down
- pvrusb2: Call sysfs_attr_init() appropriately...

 pvrusb2-devattr.c |1
 pvrusb2-devattr.h |5 
 pvrusb2-hdw.c |   26 +
 pvrusb2-main.c|4 +--
 pvrusb2-sysfs.c   |   64 +++---
 pvrusb2-v4l2.c|   16 ++---
 6 files changed, 107 insertions(+), 9 deletions(-)

These are primarily a collection of stability fixes.

Thanks,

  -Mike


-- 

Mike Isely
isely @ isely (dot) net
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Massage Therapists marketing email list

2010-05-16 Thread Beck bedazzle
Here's a business list package on sale this week only:

Business List Gold Package

Real Estate Agents - 1 million records with emails
US New Business Database - 4.8 million records all with emails
Manufacturers Database - 1,057,119 records with 476,509 emails

All complete lists above: $296


There are more packages and not just for business. we also have healthcare, 
consumers and more. Contact me here for more info or to get samples: 
successto...@gmx.com

  


Send email to remfi...@gmx.com for deleted status
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html