Re: [PATCH] media: vb2: add length check for mmap

2013-04-12 Thread Marek Szyprowski


On 4/12/2013 5:57 AM, Seung-Woo Kim wrote:

The length of mmap() can be bigger than length of vb2 buffer, so
it should be checked.

Signed-off-by: Seung-Woo Kim sw0312@samsung.com


Acked-by: Marek Szyprowski m.szyprow...@samsung.com


---
  drivers/media/v4l2-core/videobuf2-core.c |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index db1235d..2c6ff2d 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1886,6 +1886,11 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct 
*vma)
  
  	vb = q-bufs[buffer];
  
+	if (vb-v4l2_planes[plane].length  (vma-vm_end - vma-vm_start)) {

+   dprintk(1, Invalid length\n);
+   return -EINVAL;
+   }
+
ret = call_memop(q, mmap, vb-planes[plane].mem_priv, vma);
if (ret)
return ret;


Best regards
--
Marek Szyprowski
Samsung Poland RD Center


--
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 v8 0/7] V4L2 clock and async patches and soc-camera example

2013-04-12 Thread Guennadi Liakhovetski
Hi Sylwester

On Thu, 11 Apr 2013, Sylwester Nawrocki wrote:

 Hi Guennadi,
 
 On 04/11/2013 11:59 AM, Guennadi Liakhovetski wrote:
  Hi all
  
  On Mon, 8 Apr 2013, Guennadi Liakhovetski wrote:
  
 Mostly just a re-spin of v7 with minor modifications.
   
 Guennadi Liakhovetski (7):
media: V4L2: add temporary clock helpers
media: V4L2: support asynchronous subdevice registration
media: soc-camera: switch I2C subdevice drivers to use v4l2-clk
soc-camera: add V4L2-async support
sh_mobile_ceu_camera: add asynchronous subdevice probing support
imx074: support asynchronous probing
ARM: shmobile: convert ap4evb to asynchronously register camera
  subdevices
  
  So far there haven't been any comments to this, and Mauro asked to push
  all non-fixes to him by tomorrow. So, if at least the API is now ok, we
  could push this to 3.10, at least the core patches 1 and 2. Then during
  3.10 we could look at porting individual drivers on top of this.
 
 This patch series has significantly improved over time but I'm not sure
 it is all ready to merge it at this moment. At least it doesn't make sense
 to me to merge it without any users.

I wouldn't be too scared to also push my soc-camera patches from the same 
patch-series. But our V4L2 OF patches don't have many users so far either, 
right? And they aren't likely to get any until asynchronous probing is 
supported.

 The purpose of an introduction of this whole asynchronous probing concept
 was to add support for the device tree based systems. However there is no
 patch in this series that would be adding device tree support to some V4L2
 driver. That's a minor issue though I think.

It is indeed. And I did have such patches in the past, but I dropped them 
on purpose for now. It was too much work to update them all for each 
iteration, so, I picked up a testable minimum.

 A significant blocking point IMHO is that this API is bound to the circular
 dependency issue between a sub-device and the host driver. I think we should
 have at least some specific ideas on how to resolve it before pushing the
 API upstream. Or are there any already ?

Of course there is at least one. I wouldn't propose (soc-camera) patches, 
that lock modules hard into memory, once probing is complete.

 One of the ideas I had was to make a sub-device driver drop the reference
 it has to the clock provider module (the host) as soon as it gets registered
 to it. But it doesn't seem straightforward with the common clock API.

It isn't.

 Other option is a sysfs attribute at a host driver that would allow to
 release its sub-device(s). But it sounds a bit strange to me to require
 userspace to touch some sysfs attributes before being able to remove some
 modules.
 
 Something probably needs to be changed at the high level design to avoid
 this circular dependency.

Here's what I do in my soc-camera patches atm: holding a reference to a 
(V4L2) clock doesn't increment bridge driver's use-count (for this 
discussion I describe the combined soc-camera host and soc-camera core 
functionality as a bridge driver, because that's what most non soc-camera 
drivers will look like). So, it can be unloaded. Once unloaded, it 
unregisters its V4L2 async notifier. Inside that the v4l2-async framework 
first detaches the subdevice driver, then calls the notifier's .unbind() 
method, which should now unregister the clock. Then, back in 
v4l2_async_notifier_unregister() the subdevice driver is re-probed, this 
time with no clock available, so, it re-enters the deferred probing state.

BTW, a bit of self-advertisement: most soc-camera host drivers will hardly 
need any modifications to support asynchronous subdevice probing. It's all 
hidden in the soc-camera core. The sh-mobile CEU driver had to be modified 
because it supports one more subdevice - a CSI-2 interface.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
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


[GIT PULL FOR v3.10] DaVinci media cleanups + Updates

2013-04-12 Thread Prabhakar Lad
Hi Hans/Mauro,

Please pull the following patches for Davinci media. Few patches
contain platform changes for ARM which have been Acked by its maintainer.

Regards,
--Prabhakar Lad

The following changes since commit 81e096c8ac6a064854c2157e0bf802dc4906678c:

  [media] budget: Add support for Philips Semi Sylt PCI ref. design
(2013-04-08 07:28:01 -0300)

are available in the git repository at:
  git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git for_v3.10

Lad, Prabhakar (6):
  davinci: vpif: add pm_runtime support
  media: davinci: vpss: enable vpss clocks
  media: davinci: vpbe: venc: move the enabling of vpss clocks to driver
  davinic: vpss: trivial cleanup
  ARM: davinci: dm365: add support for v4l2 video display
  ARM: davinci: dm365 EVM: add support for VPBE display

Sekhar Nori (1):
  media: davinci: kconfig: fix incorrect selects

 arch/arm/mach-davinci/board-dm365-evm.c  |  166 ++-
 arch/arm/mach-davinci/davinci.h  |8 +-
 arch/arm/mach-davinci/dm355.c|7 +-
 arch/arm/mach-davinci/dm365.c|  195 +++---
 arch/arm/mach-davinci/dm644x.c   |9 +-
 arch/arm/mach-davinci/pm_domain.c|2 +-
 drivers/media/platform/davinci/Kconfig   |  103 +-
 drivers/media/platform/davinci/Makefile  |   17 +--
 drivers/media/platform/davinci/dm355_ccdc.c  |   39 +-
 drivers/media/platform/davinci/dm644x_ccdc.c |   44 --
 drivers/media/platform/davinci/isif.c|   28 +---
 drivers/media/platform/davinci/vpbe_venc.c   |   25 
 drivers/media/platform/davinci/vpif.c|   24 +---
 drivers/media/platform/davinci/vpss.c|   36 -
 14 files changed, 459 insertions(+), 244 deletions(-)
--
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: [GIT PULL FOR v3.10] DaVinci media cleanups + Updates

2013-04-12 Thread Prabhakar Lad
Hi Hans/Mauro,

I have included two more patches in the pull, following is the fresh
pull request.

Regards,
--Prabhakar

The following changes since commit 81e096c8ac6a064854c2157e0bf802dc4906678c:

  [media] budget: Add support for Philips Semi Sylt PCI ref. design
(2013-04-08 07:28:01 -0300)

are available in the git repository at:
  git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git for_v3.10

Lad, Prabhakar (8):
  davinci: vpif: add pm_runtime support
  media: davinci: vpss: enable vpss clocks
  media: davinci: vpbe: venc: move the enabling of vpss clocks to driver
  davinic: vpss: trivial cleanup
  ARM: davinci: dm365: add support for v4l2 video display
  ARM: davinci: dm365 EVM: add support for VPBE display
  ARM: davinci: dm355: add support for v4l2 video display
  ARM: davinci: dm355 EVM: add support for VPBE display

Sekhar Nori (1):
  media: davinci: kconfig: fix incorrect selects

 arch/arm/mach-davinci/board-dm355-evm.c  |   71 +-
 arch/arm/mach-davinci/board-dm365-evm.c  |  166 ++-
 arch/arm/mach-davinci/davinci.h  |   11 ++-
 arch/arm/mach-davinci/dm355.c|  174 ++--
 arch/arm/mach-davinci/dm365.c|  195 +++---
 arch/arm/mach-davinci/dm644x.c   |9 +-
 arch/arm/mach-davinci/pm_domain.c|2 +-
 drivers/media/platform/davinci/Kconfig   |  103 +-
 drivers/media/platform/davinci/Makefile  |   17 +--
 drivers/media/platform/davinci/dm355_ccdc.c  |   39 +-
 drivers/media/platform/davinci/dm644x_ccdc.c |   44 --
 drivers/media/platform/davinci/isif.c|   28 +---
 drivers/media/platform/davinci/vpbe_venc.c   |   25 
 drivers/media/platform/davinci/vpif.c|   24 +---
 drivers/media/platform/davinci/vpss.c|   36 -
 15 files changed, 692 insertions(+), 252 deletions(-)
--
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


[GIT PULL FOR v3.10] Camera sensors patches

2013-04-12 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit 81e096c8ac6a064854c2157e0bf802dc4906678c:

  [media] budget: Add support for Philips Semi Sylt PCI ref. design 
(2013-04-08 07:28:01 -0300)

are available in the git repository at:

  git://linuxtv.org/pinchartl/media.git sensors/next

for you to fetch changes up to c890926a06339944790c5c265e21e8547aa55e49:

  mt9p031: Use the common clock framework (2013-04-12 11:07:07 +0200)


Laurent Pinchart (5):
  mt9m032: Fix PLL setup
  mt9m032: Define MT9M032_READ_MODE1 bits
  mt9p031: Use devm_* managed helpers
  mt9p031: Add support for regulators
  mt9p031: Use the common clock framework

 drivers/media/i2c/mt9m032.c | 46 +++---
 drivers/media/i2c/mt9p031.c | 58 ++--
 include/media/mt9p031.h |  2 --
 3 files changed, 75 insertions(+), 31 deletions(-)

-- 
Regards,

Laurent Pinchart

--
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


[GIT PULL FOR v3.10] OMAP3 ISP patches

2013-04-12 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit 81e096c8ac6a064854c2157e0bf802dc4906678c:

  [media] budget: Add support for Philips Semi Sylt PCI ref. design 
(2013-04-08 07:28:01 -0300)

are available in the git repository at:

  git://linuxtv.org/pinchartl/media.git omap3isp/next

for you to fetch changes up to 36960bd76f1088e0cebbe47328e41045443bdc56:

  omap3isp: Use the common clock framework (2013-04-12 10:59:37 +0200)

Please note that the patch depends on

commit 533ddeb1e86f506129ee388a6cc13796dcf31311
Author: Mike Turquette mturque...@linaro.org
Date:   Thu Mar 28 13:59:02 2013 -0700

clk: allow reentrant calls into the clk framework

scheduled for v3.10.


Laurent Pinchart (1):
  omap3isp: Use the common clock framework

 drivers/media/platform/omap3isp/isp.c | 277 +++--
 drivers/media/platform/omap3isp/isp.h |  22 +++-
 include/media/omap3isp.h  |  10 +-
 3 files changed, 225 insertions(+), 84 deletions(-)

-- 
Regards,

Laurent Pinchart

--
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: v4l2-ctl-streaming: ideas for improvements

2013-04-12 Thread Laurent Pinchart
On Wednesday 10 April 2013 09:27:07 Hans Verkuil wrote:
 Hi all,
 
 Just in case someone has time to work on this: I thought I'd write down some
 of the ideas I have to improve the streaming code in v4l2-ctl:
 
 1) Add an option to select between limited and full range colors.
 
 2) Add more test patterns:
   - solid colors: black, white, red, green, blue, cyan, yellow, magenta.
   - grey 'color' bar
   - grey ramp
   - a pattern containing SAV and EAV codes in each plane (perhaps this
 should be a separate option, 'overlaying' those codes): this is a very
 nasty test case that can be used to test proper handling of such codes
 in an image.
   - moving patterns
   - horizontal colorbars
   - thin lines: horizontal, vertical, both.
   - random contents

I've implemented support for generating test patterns in both my fbdev-test 
program (http://git.ideasonboard.org/fbdev-test.git) and in the libdrm 
modetest program. Maybe we should consider splitting that to a shared library.

 3) For the capture side add pattern validation: check that the contents you
captured matches the given pattern. Very useful for testing.
 
 4) Add support for capturing/displaying frames with different sizes (e.g.
compressed streams). Currently the output just appends all planes/frames
together without writing the plane/frame sizes anywhere. The input
 assumes fixed sized planes/frames. We probably need to add a meta file that
 contains the 'bytesused' values. Perhaps that file should also contain
 format information that can be used later.
 
 5) Add some support to give keyboard commands when streaming. E.g. 'q' to
 stop streaming gracefully (and so also ensure that all the data is written
 to file, something that doesn't happen with ctrl-c).
 
Other commands for the future are encoder/decoder commands such as
 speeding up or down.
 
 6) MPEG encoders can generate an index file (VIDIOC_G_ENC_INDEX). Add an
 option to generate that and to use it when decoding. I actually have some
 old test application that does just that, and that also has encoder/decoder
 command support (see item 5 above): http://ivtvdriver.org/svn/ivtvtv
 
 7) Add VBI streaming support. Split off the VBI code from qv4l2 into a
 library and use that in v4l2-ctl to slice the raw VBI and to interpret the
 data. That should replace the vbi-test.c, sliced-vbi-detect.c and
 sliced-vbi-test.c utilities in contrib.

-- 
Regards,

Laurent Pinchart

--
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: v4l2-ctl-streaming: ideas for improvements

2013-04-12 Thread Hans Verkuil
On Fri April 12 2013 11:31:36 Laurent Pinchart wrote:
 On Wednesday 10 April 2013 09:27:07 Hans Verkuil wrote:
  Hi all,
  
  Just in case someone has time to work on this: I thought I'd write down some
  of the ideas I have to improve the streaming code in v4l2-ctl:
  
  1) Add an option to select between limited and full range colors.
  
  2) Add more test patterns:
  - solid colors: black, white, red, green, blue, cyan, yellow, magenta.
  - grey 'color' bar
  - grey ramp
  - a pattern containing SAV and EAV codes in each plane (perhaps this
should be a separate option, 'overlaying' those codes): this is a very
nasty test case that can be used to test proper handling of such codes
in an image.
  - moving patterns
  - horizontal colorbars
  - thin lines: horizontal, vertical, both.
  - random contents
 
 I've implemented support for generating test patterns in both my fbdev-test 
 program (http://git.ideasonboard.org/fbdev-test.git) and in the libdrm 
 modetest program. Maybe we should consider splitting that to a shared library.

Good to know.

One idea I have is to split off test pattern generation from vivi into its own
source and sync that with v4l-utils ('make sync-with-kernel'). Having both vivi
and a v4l-utils test-pattern library support the same patterns/formats would
be beneficial in my opinion.

Regards,

Hans

 
  3) For the capture side add pattern validation: check that the contents you
 captured matches the given pattern. Very useful for testing.
  
  4) Add support for capturing/displaying frames with different sizes (e.g.
 compressed streams). Currently the output just appends all planes/frames
 together without writing the plane/frame sizes anywhere. The input
  assumes fixed sized planes/frames. We probably need to add a meta file that
  contains the 'bytesused' values. Perhaps that file should also contain
  format information that can be used later.
  
  5) Add some support to give keyboard commands when streaming. E.g. 'q' to
  stop streaming gracefully (and so also ensure that all the data is written
  to file, something that doesn't happen with ctrl-c).
  
 Other commands for the future are encoder/decoder commands such as
  speeding up or down.
  
  6) MPEG encoders can generate an index file (VIDIOC_G_ENC_INDEX). Add an
  option to generate that and to use it when decoding. I actually have some
  old test application that does just that, and that also has encoder/decoder
  command support (see item 5 above): http://ivtvdriver.org/svn/ivtvtv
  
  7) Add VBI streaming support. Split off the VBI code from qv4l2 into a
  library and use that in v4l2-ctl to slice the raw VBI and to interpret the
  data. That should replace the vbi-test.c, sliced-vbi-detect.c and
  sliced-vbi-test.c utilities in contrib.
 
 
--
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

2013-04-12 Thread Hans Verkuil
Hi all,

Some recent discussions regarding the correct behavior of QUERYSTD brought up
a feeling of déjà vu. Some digging in my mail history resulted in this three
year old RFC which I promised to implement but obviously I never did.

Things have changed a bit. Today v4l_querystd in v4l2-ioctl.c initializes the
std with the tvnorms mask (i.e. the list of supported standards), and then it
calls vidioc_querystd. In most cases vidioc_querystd just calls the querystd op
of all registered sub-devices. The idea is that those subdevices will clear any
std bits that they do not detect. So it makes perfect sense that if no signal
is detected at all the end result is 0 == V4L2_STD_UNKNOWN.

I'd like to go through all drivers and ensure that they implement this behavior
and (very important) update the V4L2 spec accordingly.

Comments?

Regards,

Hans

On Sun May 16 2010 10:26:04 Hans Verkuil wrote:
 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
  
  
 
 
--
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: Pixel Formats

2013-04-12 Thread Laurent Pinchart
(A bit late, sorry)

On Thursday 07 March 2013 22:37:26 Guennadi Liakhovetski wrote:
 On Wed, 6 Mar 2013, Christian Rhodin wrote:
  Hi,
  
  I'm looking for some guidance on the correct way to handle a new pixel
  format.  What I'm dealing with is a CMOS image sensor that supports
  dynamic switching between linear and iHDR modes.  iHDR stands for
  interlaced High Dynamic Range and is a mode where odd and even lines
  have different exposure times, typically with an 8:1 ratio.  When I
  started implementing a driver for this sensor I used
  V4L2_MBUS_FMT_SGRBG10_1X10 as the format for the linear mode and
  defined a new format V4L2_MBUS_FMT_SGRBG10_IHDR_1X10 for the iHDR
  mode.  I used the format to control which mode I put the sensor in.  But
  now I'm having trouble switching modes without reinitializing the
  sensor.  Does anyone (everyone?) have an opinion about the correct way
  to implement this?  I'm thinking that the format is overloaded because
  it represents both the size and type of the data.  Should I use a single
  format and add a control to switch the mode?
 
 I would vote for a single format with a control, maybe even somehow
 cluster it with the normal exposure, but I'm not an expert in that, not
 sure if it would make sense.

From the above explanation about iHDR I assume that enabling iHDR mode 
produces an image with the same resolution as linear mode, not an image with 8 
times the number of lines compared to the linear mode. Please correct me if 
I'm wrong.

If my understanding of iHDR mode is correct, I agree with Guennadi. I don't 
think enabling iHDR changes the format, it just modifies the exposure time 
algorithm. A V4L2 control would thus be better than adding an iHDR variant to 
all existing formats.

-- 
Regards,

Laurent Pinchart

--
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 2/2] [media] bfin_capture: add query_dv_timings/enum_dv_timings support

2013-04-12 Thread Scott Jiang
More dv_timings ioctl ops are introduced in video core.
Add query_dv_timings/enum_dv_timings accordingly.

Signed-off-by: Scott Jiang scott.jiang.li...@gmail.com
---
 drivers/media/platform/blackfin/bfin_capture.c |   28 ++--
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/blackfin/bfin_capture.c 
b/drivers/media/platform/blackfin/bfin_capture.c
index 5f209d5..1d58846 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -649,18 +649,30 @@ static int bcap_s_std(struct file *file, void *priv, 
v4l2_std_id *std)
return 0;
 }
 
-static int bcap_g_dv_timings(struct file *file, void *priv,
+static int bcap_enum_dv_timings(struct file *file, void *priv,
+   struct v4l2_enum_dv_timings *timings)
+{
+   struct bcap_device *bcap_dev = video_drvdata(file);
+
+   return v4l2_subdev_call(bcap_dev-sd, video,
+   enum_dv_timings, timings);
+}
+
+static int bcap_query_dv_timings(struct file *file, void *priv,
struct v4l2_dv_timings *timings)
 {
struct bcap_device *bcap_dev = video_drvdata(file);
-   int ret;
 
-   ret = v4l2_subdev_call(bcap_dev-sd, video,
-   g_dv_timings, timings);
-   if (ret  0)
-   return ret;
+   return v4l2_subdev_call(bcap_dev-sd, video,
+   query_dv_timings, timings);
+}
 
-   bcap_dev-dv_timings = *timings;
+static int bcap_g_dv_timings(struct file *file, void *priv,
+   struct v4l2_dv_timings *timings)
+{
+   struct bcap_device *bcap_dev = video_drvdata(file);
+
+   *timings = bcap_dev-dv_timings;
return 0;
 }
 
@@ -921,6 +933,8 @@ static const struct v4l2_ioctl_ops bcap_ioctl_ops = {
.vidioc_g_std= bcap_g_std,
.vidioc_s_dv_timings = bcap_s_dv_timings,
.vidioc_g_dv_timings = bcap_g_dv_timings,
+   .vidioc_query_dv_timings = bcap_query_dv_timings,
+   .vidioc_enum_dv_timings  = bcap_enum_dv_timings,
.vidioc_reqbufs  = bcap_reqbufs,
.vidioc_querybuf = bcap_querybuf,
.vidioc_qbuf = bcap_qbuf,
-- 
1.7.0.4


--
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 1/2] [media] blackfin: add display support in ppi driver

2013-04-12 Thread Scott Jiang
Signed-off-by: Scott Jiang scott.jiang.li...@gmail.com
---
 drivers/media/platform/blackfin/ppi.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/media/platform/blackfin/ppi.c 
b/drivers/media/platform/blackfin/ppi.c
index 01b5b50..15e9c2b 100644
--- a/drivers/media/platform/blackfin/ppi.c
+++ b/drivers/media/platform/blackfin/ppi.c
@@ -266,6 +266,18 @@ static int ppi_set_params(struct ppi_if *ppi, struct 
ppi_params *params)
bfin_write32(reg-vcnt, params-height);
if (params-int_mask)
bfin_write32(reg-imsk, params-int_mask  0xFF);
+   if (ppi-ppi_control  PORT_DIR) {
+   u32 hsync_width, vsync_width, vsync_period;
+
+   hsync_width = params-hsync
+   * params-bpp / params-dlen;
+   vsync_width = params-vsync * samples_per_line;
+   vsync_period = samples_per_line * params-frame;
+   bfin_write32(reg-fs1_wlhb, hsync_width);
+   bfin_write32(reg-fs1_paspl, samples_per_line);
+   bfin_write32(reg-fs2_wlvb, vsync_width);
+   bfin_write32(reg-fs2_palpf, vsync_period);
+   }
break;
}
default:
-- 
1.7.0.4


--
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 RFC] [media] blackfin: add video display driver

2013-04-12 Thread Scott Jiang
This is a bridge driver for blackfin diplay device.
It can work with ppi or eppi interface. DV timings
are supported.

Signed-off-by: Scott Jiang scott.jiang.li...@gmail.com
---
 drivers/media/platform/blackfin/Kconfig|   15 +-
 drivers/media/platform/blackfin/Makefile   |1 +
 drivers/media/platform/blackfin/bfin_display.c | 1151 
 include/media/blackfin/bfin_display.h  |   38 +
 4 files changed, 1203 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/platform/blackfin/bfin_display.c
 create mode 100644 include/media/blackfin/bfin_display.h

diff --git a/drivers/media/platform/blackfin/Kconfig 
b/drivers/media/platform/blackfin/Kconfig
index cc23997..8a8fd75 100644
--- a/drivers/media/platform/blackfin/Kconfig
+++ b/drivers/media/platform/blackfin/Kconfig
@@ -9,7 +9,18 @@ config VIDEO_BLACKFIN_CAPTURE
  To compile this driver as a module, choose M here: the
  module will be called bfin_capture.
 
+config VIDEO_BLACKFIN_DISPLAY
+   tristate Blackfin Video Display Driver
+   depends on VIDEO_V4L2  BLACKFIN  I2C
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ V4L2 bridge driver for Blackfin video display device.
+ Choose PPI or EPPI as its interface.
+
+ To compile this driver as a module, choose M here: the
+ module will be called bfin_display.
+
 config VIDEO_BLACKFIN_PPI
tristate
-   depends on VIDEO_BLACKFIN_CAPTURE
-   default VIDEO_BLACKFIN_CAPTURE
+   depends on VIDEO_BLACKFIN_CAPTURE || VIDEO_BLACKFIN_DISPLAY
+   default VIDEO_BLACKFIN_CAPTURE || VIDEO_BLACKFIN_DISPLAY
diff --git a/drivers/media/platform/blackfin/Makefile 
b/drivers/media/platform/blackfin/Makefile
index 30421bc..015c8f0 100644
--- a/drivers/media/platform/blackfin/Makefile
+++ b/drivers/media/platform/blackfin/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_VIDEO_BLACKFIN_CAPTURE) += bfin_capture.o
+obj-$(CONFIG_VIDEO_BLACKFIN_DISPLAY) += bfin_display.o
 obj-$(CONFIG_VIDEO_BLACKFIN_PPI) += ppi.o
diff --git a/drivers/media/platform/blackfin/bfin_display.c 
b/drivers/media/platform/blackfin/bfin_display.c
new file mode 100644
index 000..d971d7b
--- /dev/null
+++ b/drivers/media/platform/blackfin/bfin_display.c
@@ -0,0 +1,1151 @@
+/*
+ * Analog Devices video display driver
+ *
+ * Copyright (c) 2011 Analog Devices Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/completion.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/fs.h
+#include linux/i2c.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/mm.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/slab.h
+#include linux/time.h
+#include linux/types.h
+
+#include media/v4l2-chip-ident.h
+#include media/v4l2-common.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/videobuf2-dma-contig.h
+
+#include asm/dma.h
+
+#include media/blackfin/bfin_display.h
+#include media/blackfin/ppi.h
+
+#define DISPLAY_DRV_NAMEbfin_display
+#define DISP_MIN_NUM_BUF2
+
+struct disp_format {
+   char *desc;
+   u32 pixelformat;
+   enum v4l2_mbus_pixelcode mbus_code;
+   int bpp; /* bits per pixel */
+   int dlen; /* data length for ppi in bits */
+};
+
+struct disp_buffer {
+   struct vb2_buffer vb;
+   struct list_head list;
+};
+
+struct disp_device {
+   /* capture device instance */
+   struct v4l2_device v4l2_dev;
+   /* v4l2 control handler */
+   struct v4l2_ctrl_handler ctrl_handler;
+   /* device node data */
+   struct video_device *video_dev;
+   /* sub device instance */
+   struct v4l2_subdev *sd;
+   /* capture config */
+   struct bfin_display_config *cfg;
+   /* ppi interface */
+   struct ppi_if *ppi;
+   /* current output */
+   unsigned int cur_output;
+   /* current selected standard */
+   v4l2_std_id std;
+   /* current selected dv_timings */
+   struct v4l2_dv_timings dv_timings;
+   /* used to store pixel format */
+   struct v4l2_pix_format fmt;
+   /* bits per pixel*/
+   int bpp;
+   /* data length for ppi in bits */
+   int dlen;
+   /* used to store encoder supported format */
+   struct disp_format *enc_formats;
+   /* number of encoder formats array */
+   int num_enc_formats;
+   /* pointing to current video buffer */
+   struct disp_buffer *cur_frm;
+   /* buffer queue used in videobuf2 */
+   struct vb2_queue 

Re: [PATCH] ARM: daVinci: dm644x/dm355/dm365: replace V4L2_STD_525_60/625_50 with V4L2_STD_NTSC/PAL

2013-04-12 Thread Prabhakar Lad
Sekhar,

On Fri, Apr 12, 2013 at 4:50 PM, Sekhar Nori nsek...@ti.com wrote:


 On 4/12/2013 4:35 PM, Prabhakar lad wrote:
 From: Lad, Prabhakar prabhakar.cse...@gmail.com

 This patch replaces V4L2_STD_525_60/625_50 with V4L2_STD_NTSC/PAL
 respectively as this are the proper video standards.

 Signed-off-by: Lad, Prabhakar prabhakar.cse...@gmail.com
 Reported-by: Hans Verkuil hans.verk...@cisco.com
 Cc: Sekhar Nori nsek...@ti.com

 I assume you have tested it, some testing information would have been
 good. The patch as such is OK with me. I assume this will go through
 media tree for sake of dependencies.

 Acked-by: Sekhar Nori nsek...@ti.com

Thanks for the ACK, Yes I have tested the patch. missed to add the tested info.
And yes this patch will go via media tree.

Regards,
--Prabhakar

 Thanks,
 Sekhar

 ---
  Note:- This patch is on top of following pull
   https://patchwork.linuxtv.org/patch/17888/

  arch/arm/mach-davinci/board-dm355-evm.c  |4 ++--
  arch/arm/mach-davinci/board-dm365-evm.c  |4 ++--
  arch/arm/mach-davinci/board-dm644x-evm.c |4 ++--
  3 files changed, 6 insertions(+), 6 deletions(-)

 diff --git a/arch/arm/mach-davinci/board-dm355-evm.c 
 b/arch/arm/mach-davinci/board-dm355-evm.c
 index 1043506..886481c 100644
 --- a/arch/arm/mach-davinci/board-dm355-evm.c
 +++ b/arch/arm/mach-davinci/board-dm355-evm.c
 @@ -247,7 +247,7 @@ static struct vpbe_enc_mode_info 
 dm355evm_enc_preset_timing[] = {
   {
   .name   = ntsc,
   .timings_type   = VPBE_ENC_STD,
 - .std_id = V4L2_STD_525_60,
 + .std_id = V4L2_STD_NTSC,
   .interlaced = 1,
   .xres   = 720,
   .yres   = 480,
 @@ -259,7 +259,7 @@ static struct vpbe_enc_mode_info 
 dm355evm_enc_preset_timing[] = {
   {
   .name   = pal,
   .timings_type   = VPBE_ENC_STD,
 - .std_id = V4L2_STD_625_50,
 + .std_id = V4L2_STD_PAL,
   .interlaced = 1,
   .xres   = 720,
   .yres   = 576,
 diff --git a/arch/arm/mach-davinci/board-dm365-evm.c 
 b/arch/arm/mach-davinci/board-dm365-evm.c
 index 0518ce5..2a66743 100644
 --- a/arch/arm/mach-davinci/board-dm365-evm.c
 +++ b/arch/arm/mach-davinci/board-dm365-evm.c
 @@ -381,7 +381,7 @@ static struct vpbe_enc_mode_info 
 dm365evm_enc_std_timing[] = {
   {
   .name   = ntsc,
   .timings_type   = VPBE_ENC_STD,
 - .std_id = V4L2_STD_525_60,
 + .std_id = V4L2_STD_NTSC,
   .interlaced = 1,
   .xres   = 720,
   .yres   = 480,
 @@ -393,7 +393,7 @@ static struct vpbe_enc_mode_info 
 dm365evm_enc_std_timing[] = {
   {
   .name   = pal,
   .timings_type   = VPBE_ENC_STD,
 - .std_id = V4L2_STD_625_50,
 + .std_id = V4L2_STD_PAL,
   .interlaced = 1,
   .xres   = 720,
   .yres   = 576,
 diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c 
 b/arch/arm/mach-davinci/board-dm644x-evm.c
 index a021800..745280d 100644
 --- a/arch/arm/mach-davinci/board-dm644x-evm.c
 +++ b/arch/arm/mach-davinci/board-dm644x-evm.c
 @@ -622,7 +622,7 @@ static struct vpbe_enc_mode_info 
 dm644xevm_enc_std_timing[] = {
   {
   .name   = ntsc,
   .timings_type   = VPBE_ENC_STD,
 - .std_id = V4L2_STD_525_60,
 + .std_id = V4L2_STD_NTSC,
   .interlaced = 1,
   .xres   = 720,
   .yres   = 480,
 @@ -634,7 +634,7 @@ static struct vpbe_enc_mode_info 
 dm644xevm_enc_std_timing[] = {
   {
   .name   = pal,
   .timings_type   = VPBE_ENC_STD,
 - .std_id = V4L2_STD_625_50,
 + .std_id = V4L2_STD_PAL,
   .interlaced = 1,
   .xres   = 720,
   .yres   = 576,

--
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 1/2] [media] blackfin: add display support in ppi driver

2013-04-12 Thread Hans Verkuil
On Sat April 13 2013 01:52:57 Scott Jiang wrote:
 Signed-off-by: Scott Jiang scott.jiang.li...@gmail.com

Is it OK if I postpone these two patches for 3.11? They don't make sense
AFAICT without the new display driver, and that will definitely not make it
for 3.10.

Regards,

Hans

 ---
  drivers/media/platform/blackfin/ppi.c |   12 
  1 files changed, 12 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/media/platform/blackfin/ppi.c 
 b/drivers/media/platform/blackfin/ppi.c
 index 01b5b50..15e9c2b 100644
 --- a/drivers/media/platform/blackfin/ppi.c
 +++ b/drivers/media/platform/blackfin/ppi.c
 @@ -266,6 +266,18 @@ static int ppi_set_params(struct ppi_if *ppi, struct 
 ppi_params *params)
   bfin_write32(reg-vcnt, params-height);
   if (params-int_mask)
   bfin_write32(reg-imsk, params-int_mask  0xFF);
 + if (ppi-ppi_control  PORT_DIR) {
 + u32 hsync_width, vsync_width, vsync_period;
 +
 + hsync_width = params-hsync
 + * params-bpp / params-dlen;
 + vsync_width = params-vsync * samples_per_line;
 + vsync_period = samples_per_line * params-frame;
 + bfin_write32(reg-fs1_wlhb, hsync_width);
 + bfin_write32(reg-fs1_paspl, samples_per_line);
 + bfin_write32(reg-fs2_wlvb, vsync_width);
 + bfin_write32(reg-fs2_palpf, vsync_period);
 + }
   break;
   }
   default:
 
--
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 v2 2/2] adv7180: add more subdev video ops

2013-04-12 Thread Sergei Shtylyov

Hello.

On 12-04-2013 12:05, Hans Verkuil wrote:


Thanks for the patch!



I've got some comments about this, though.



See below:



On Fri April 12 2013 00:08:09 Sergei Shtylyov wrote:

From: Vladimir Barinov vladimir.bari...@cogentembedded.com



Add subdev video ops for ADV7180 video decoder.  This makes decoder usable on
the soc-camera drivers.



Signed-off-by: Vladimir Barinov vladimir.bari...@cogentembedded.com
Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com



---
  drivers/media/i2c/adv7180.c |  105 

  1 file changed, 105 insertions(+)



Index: linux/drivers/media/i2c/adv7180.c
===
--- linux.orig/drivers/media/i2c/adv7180.c
+++ linux/drivers/media/i2c/adv7180.c

[...]

@@ -397,10 +400,112 @@ static void adv7180_exit_controls(struct
v4l2_ctrl_handler_free(state-ctrl_hdl);
  }

+static int adv7180_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index,
+enum v4l2_mbus_pixelcode *code)
+{
+   if (index  0)
+   return -EINVAL;
+
+   *code = V4L2_MBUS_FMT_YUYV8_2X8;
+
+   return 0;
+}
+
+static int adv7180_try_mbus_fmt(struct v4l2_subdev *sd,
+   struct v4l2_mbus_framefmt *fmt)
+{
+   struct adv7180_state *state = to_state(sd);
+
+   adv7180_querystd(sd, state-curr_norm);



No, you must use the currently set std here. What querystd returns is
effectively unpredictable, and that defeats the purpose of this try
function. It is always up to the application to call querystd and then
call s_std to set the standard explicitly. The same problem applies to
the other calls to querystd in this patch.


   The current set/change of std is implemented in the initialization stage 
or in the interrupt handler. So it is not able to catch the change of STD if 
the h/w do not use the ADC7180 IRQ line. Implementation of polling scheme for 
systems without IRQ line used will provide unnecessary overhead. Hence the 
adv7180_querystd was added in order to update the state-curr_norm. Should 
this be changed to:


+if (!state-irq)
+adv7180_querystd(sd, state-curr_norm);

?

[...]

+static int adv7180_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
+{
+   struct adv7180_state *state = to_state(sd);
+
+   adv7180_querystd(sd, state-curr_norm);
+
+   a-bounds.left = 0;
+   a-bounds.top = 0;
+   a-bounds.width = 720;
+   a-bounds.height = state-curr_norm  V4L2_STD_525_60 ? 480 : 576;
+   a-defrect = a-bounds;
+   a-type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+   a-pixelaspect.numerator = 1;
+   a-pixelaspect.denominator = 1;
+
+   return 0;
+}
+
+static int adv7180_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
+{
+   struct adv7180_state *state = to_state(sd);
+
+   adv7180_querystd(sd, state-curr_norm);
+
+   a-c.left = 0;
+   a-c.top = 0;
+   a-c.width = 720;
+   a-c.height = state-curr_norm  V4L2_STD_525_60 ? 480 : 576;
+   a-type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+   return 0;
+}



You are not actually implementing any cropping, so are these two ops really
necessary?


   Thank you for the comment.
   You are right, cropping and not implemented and g_crop is not a demand for 
camera-soc
(the sample for minimal ops needed for camera-soc was taken from 
drivers/media/platform/
soc_camera/soc_camera_platform.c that also does not implement cropping via 
s_crop), but
cropcap currently is needed by some soc-camera drivers in order to determine 
the default

rectangle.

[...]


Regards,
Hans


WBR, Sergei

--
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: [GIT PULL FOR v3.10] DaVinci media cleanups + Updates

2013-04-12 Thread Prabhakar Lad
Hi Hans/Mauro,

Ahh here is the final pull request hopefully I wont add anymore :)
sorry for inconvenience,
had to add on more patch at the final moment. Following is the fresh
pull request.
Let me know if replying on top if it is OK or if if you want a fresh mail.

Note: All the ARM platform changes have been acked by its maintainer.

Regards,
--Prabhakar

The following changes since commit 81e096c8ac6a064854c2157e0bf802dc4906678c:

  [media] budget: Add support for Philips Semi Sylt PCI ref. design
(2013-04-08 07:28:01 -0300)

are available in the git repository at:
  git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git for_v3.10

Lad, Prabhakar (9):
  davinci: vpif: add pm_runtime support
  media: davinci: vpss: enable vpss clocks
  media: davinci: vpbe: venc: move the enabling of vpss clocks to driver
  davinic: vpss: trivial cleanup
  ARM: davinci: dm365: add support for v4l2 video display
  ARM: davinci: dm365 EVM: add support for VPBE display
  ARM: davinci: dm355: add support for v4l2 video display
  ARM: davinci: dm355 EVM: add support for VPBE display
  ARM: daVinci: dm644x/dm355/dm365: replace V4L2_STD_525_60/625_50
with V4L2_STD_NTSC/PAL

Sekhar Nori (1):
  media: davinci: kconfig: fix incorrect selects

 arch/arm/mach-davinci/board-dm355-evm.c  |   71 +-
 arch/arm/mach-davinci/board-dm365-evm.c  |  166 ++-
 arch/arm/mach-davinci/board-dm644x-evm.c |4 +-
 arch/arm/mach-davinci/davinci.h  |   11 ++-
 arch/arm/mach-davinci/dm355.c|  174 ++--
 arch/arm/mach-davinci/dm365.c|  195 +++---
 arch/arm/mach-davinci/dm644x.c   |9 +-
 arch/arm/mach-davinci/pm_domain.c|2 +-
 drivers/media/platform/davinci/Kconfig   |  103 +-
 drivers/media/platform/davinci/Makefile  |   17 +--
 drivers/media/platform/davinci/dm355_ccdc.c  |   39 +-
 drivers/media/platform/davinci/dm644x_ccdc.c |   44 --
 drivers/media/platform/davinci/isif.c|   28 +---
 drivers/media/platform/davinci/vpbe_venc.c   |   25 
 drivers/media/platform/davinci/vpif.c|   24 +---
 drivers/media/platform/davinci/vpss.c|   36 -
 16 files changed, 694 insertions(+), 254 deletions(-)
--
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 v8 2/7] media: V4L2: support asynchronous subdevice registration

2013-04-12 Thread Laurent Pinchart
Hi Guennadi,

Thanks for the patch.

On Monday 08 April 2013 17:05:33 Guennadi Liakhovetski wrote:
 Currently bridge device drivers register devices for all subdevices
 synchronously, tupically, during their probing. E.g. if an I2C CMOS sensor
 is attached to a video bridge device, the bridge driver will create an I2C
 device and wait for the respective I2C driver to probe. This makes linking
 of devices straight forward, but this approach cannot be used with
 intrinsically asynchronous and unordered device registration systems like
 the Flattened Device Tree. To support such systems this patch adds an
 asynchronous subdevice registration framework to V4L2. To use it respective
 (e.g. I2C) subdevice drivers must register themselves with the framework.
 A bridge driver on the other hand must register notification callbacks,
 that will be called upon various related events.
 
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---
 
 v8: Really renamed V4L2_ASYNC_BUS_SPECIAL to V4L2_ASYNC_BUS_CUSTOM

Each iteration gets better :-)

  drivers/media/v4l2-core/Makefile |3 +-
  drivers/media/v4l2-core/v4l2-async.c |  262 +++
  include/media/v4l2-async.h   |  104 ++
  3 files changed, 368 insertions(+), 1 deletions(-)
  create mode 100644 drivers/media/v4l2-core/v4l2-async.c
  create mode 100644 include/media/v4l2-async.h

[snip]

 diff --git a/drivers/media/v4l2-core/v4l2-async.c
 b/drivers/media/v4l2-core/v4l2-async.c new file mode 100644
 index 000..4cc56ad
 --- /dev/null
 +++ b/drivers/media/v4l2-core/v4l2-async.c
 @@ -0,0 +1,262 @@
 +/*
 + * V4L2 asynchronous subdevice registration API
 + *
 + * Copyright (C) 2012-2013, Guennadi Liakhovetski g.liakhovet...@gmx.de
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/device.h
 +#include linux/err.h
 +#include linux/i2c.h
 +#include linux/list.h
 +#include linux/module.h
 +#include linux/mutex.h
 +#include linux/platform_device.h
 +#include linux/slab.h
 +#include linux/types.h
 +
 +#include media/v4l2-async.h
 +#include media/v4l2-device.h
 +#include media/v4l2-subdev.h
 +
 +static bool match_i2c(struct device *dev, struct v4l2_async_hw_device
 *hw_dev)
 +{
 + struct i2c_client *client = i2c_verify_client(dev);
 + return client 
 + hw_dev-bus_type == V4L2_ASYNC_BUS_I2C 
 + hw_dev-match.i2c.adapter_id == client-adapter-nr 
 + hw_dev-match.i2c.address == client-addr;
 +}
 +
 +static bool match_platform(struct device *dev, struct v4l2_async_hw_device
 *hw_dev)
 +{
 + return hw_dev-bus_type == V4L2_ASYNC_BUS_PLATFORM 
 + !strcmp(hw_dev-match.platform.name, dev_name(dev));
 +}
 +
 +static LIST_HEAD(subdev_list);
 +static LIST_HEAD(notifier_list);
 +static DEFINE_MUTEX(list_lock);
 +
 +static struct v4l2_async_subdev *v4l2_async_belongs(struct
 v4l2_async_notifier *notifier,
 + struct 
 v4l2_async_subdev_list *asdl)
 +{
 + struct v4l2_async_subdev *asd = NULL;
 + bool (*match)(struct device *,
 +   struct v4l2_async_hw_device *);
 +
 + list_for_each_entry (asd, notifier-waiting, list) {
 + struct v4l2_async_hw_device *hw = asd-hw;
 + switch (hw-bus_type) {
 + case V4L2_ASYNC_BUS_CUSTOM:
 + match = hw-match.special.match;
 + if (!match)
 + /* Match always */
 + return asd;
 + break;
 + case V4L2_ASYNC_BUS_PLATFORM:
 + match = match_platform;
 + break;
 + case V4L2_ASYNC_BUS_I2C:
 + match = match_i2c;
 + break;
 + default:
 + /* Oops */
 + match = NULL;
 + dev_err(notifier-v4l2_dev ? notifier-v4l2_dev-dev : 
 NULL,
 + Invalid bus-type %u on %p\n, hw-bus_type, 
 asd);

An invalid hw-bus_type value is a driver (or board code) bug. Could you move 
this check to v4l2_async_notifier_register() when building the subdev list and 
return an error ?

 + }
 +
 + if (match  match(asdl-dev, hw))
 + break;
 + }
 +
 + return asd;
 +}
 +
 +static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
 +   struct v4l2_async_subdev_list *asdl,
 +   struct v4l2_async_subdev *asd)
 +{
 + int ret;
 +
 + /* Remove from the waiting list */
 + list_del(asd-list);
 + asdl-asd = asd;
 + asdl-notifier = notifier;
 +
 + if (notifier-bound) {
 + ret = notifier-bound(notifier, asdl);
 + if (ret  0)
 +   

Re: [PATCH] drivers: media: platform: convert to devm_ioremap_resource()

2013-04-12 Thread Guennadi Liakhovetski
Hi

On Wed, 10 Apr 2013, Silviu-Mihai Popescu wrote:

 Convert all uses of devm_request_and_ioremap() to the newly introduced
 devm_ioremap_resource() which provides more consistent error handling.
 
 Signed-off-by: Silviu-Mihai Popescu silviupopescu1...@gmail.com

Thanks for the patch, but an equivalent one is already upstream:

http://git.linuxtv.org/media_tree.git/commitdiff/f2b4dc1a0fc8f52e06025497ce9bb252ff51f15f

Thanks
Guennadi

 ---
  drivers/media/platform/sh_veu.c |6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c
 index cb54c69..911f562 100644
 --- a/drivers/media/platform/sh_veu.c
 +++ b/drivers/media/platform/sh_veu.c
 @@ -1164,9 +1164,9 @@ static int sh_veu_probe(struct platform_device *pdev)
  
   veu-is_2h = resource_size(reg_res) == 0x22c;
  
 - veu-base = devm_request_and_ioremap(pdev-dev, reg_res);
 - if (!veu-base)
 - return -ENOMEM;
 + veu-base = devm_ioremap_resource(pdev-dev, reg_res);
 + if (IS_ERR(veu-base))
 + return PTR_ERR(veu-base);
  
   ret = devm_request_threaded_irq(pdev-dev, irq, sh_veu_isr, sh_veu_bh,
   0, veu, veu);
 -- 
 1.7.9.5
 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
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


[GIT PULL FOR v3.10] V4L2 patches

2013-04-12 Thread Hans Verkuil
Hi Mauro,

Here is my set of pending V4L2 patches for 3.10.

Patchwork has been updated accordingly.

Regards,

Hans

The following changes since commit 81e096c8ac6a064854c2157e0bf802dc4906678c:

  [media] budget: Add support for Philips Semi Sylt PCI ref. design (2013-04-08 
07:28:01 -0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-mauro1

for you to fetch changes up to a5d57a4138b7d45a4d72645c2ac500bbffc5ec36:

  ARM: daVinci: dm644x/dm355/dm365: replace V4L2_STD_525_60/625_50 with 
V4L2_STD_NTSC/PAL (2013-04-12 14:02:31 +0200)


Antti Palosaari (1):
  MAINTAINERS: update CYPRESS_FIRMWARE media driver

Frank Schaefer (2):
  em28xx: fix snapshot button support
  em28xx: improve em2710/em2820 distinction

Hans Verkuil (30):
  tuner-core/tda9887: get_afc can be tuner mode specific
  tuner-core/simple: get_rf_strength can be tuner mode specific
  v4l2: put VIDIOC_DBG_G_CHIP_NAME under ADV_DEBUG.
  v4l2: drop V4L2_CHIP_MATCH_SUBDEV_NAME.
  v4l2-ioctl: fill in name before calling vidioc_g_chip_name
  v4l2: rename VIDIOC_DBG_G_CHIP_NAME to _CHIP_INFO
  videodev2.h: increase size of 'reserved' array.
  em28xx: fix kernel oops when watching digital TV
  radio-si4713: remove audout ioctls
  radio-si4713: embed struct video_device instead of allocating it.
  radio-si4713: improve querycap
  radio-si4713: use V4L2 core lock.
  radio-si4713: fix g/s_frequency
  radio-si4713: convert to the control framework
  radio-si4713: add prio checking and control events.
  videodev2.h: fix incorrect V4L2_DV_FL_HALF_LINE bitmask.
  v4l2-dv-timings.h: add 480i59.94 and 576i50 CEA-861-E timings.
  hdpvr: convert to the control framework.
  hdpvr: remove hdpvr_fh and just use v4l2_fh.
  hdpvr: add prio and control event support.
  hdpvr: support device_caps in querycap.
  hdpvr: small fixes
  hdpvr: register the video node at the end of probe.
  hdpvr: recognize firmware version 0x1e.
  hdpvr: add g/querystd, remove deprecated current_norm.
  hdpvr: add dv_timings support.
  hdpvr: allow g/s/enum/querystd when in legacy mode.
  MAINTAINERS: add hdpvr entry.
  dt3155v4l: fix incorrect mutex locking.
  dt3155v4l: fix timestamp handling.

Lad, Prabhakar (9):
  davinci: vpif: add pm_runtime support
  media: davinci: vpss: enable vpss clocks
  media: davinci: vpbe: venc: move the enabling of vpss clocks to driver
  davinic: vpss: trivial cleanup
  ARM: davinci: dm365: add support for v4l2 video display
  ARM: davinci: dm365 EVM: add support for VPBE display
  ARM: davinci: dm355: add support for v4l2 video display
  ARM: davinci: dm355 EVM: add support for VPBE display
  ARM: daVinci: dm644x/dm355/dm365: replace V4L2_STD_525_60/625_50 with 
V4L2_STD_NTSC/PAL

Ondrej Zary (8):
  saa7134: v4l2-compliance: implement V4L2_CAP_DEVICE_CAPS
  saa7134: v4l2-compliance: don't report invalid audio modes for radio
  saa7134: v4l2-compliance: use v4l2_fh to fix priority handling
  saa7134: v4l2-compliance: return real frequency
  saa7134: v4l2-compliance: fix g_tuner/s_tuner
  saa7134: v4l2-compliance: remove bogus audio input support
  saa7134: v4l2-compliance: remove bogus g_parm
  saa7134: v4l2-compliance: clear reserved part of VBI structure

Randy Dunlap (1):
  media: Fix randconfig error

Sekhar Nori (1):
  media: davinci: kconfig: fix incorrect selects

Vladimir Barinov (1):
  adv7180: fix querystd() method for no input signal

 Documentation/DocBook/media/v4l/compat.xml 
 |2 +-
 Documentation/DocBook/media/v4l/v4l2.xml   
 |4 +-
 Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml
 |7 +-
 .../media/v4l/{vidioc-dbg-g-chip-name.xml = vidioc-dbg-g-chip-info.xml}   
 |   41 +-
 Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml  
 |   27 +-
 MAINTAINERS
 |   28 +-
 arch/arm/mach-davinci/board-dm355-evm.c
 |   71 ++-
 arch/arm/mach-davinci/board-dm365-evm.c
 |  166 +-
 arch/arm/mach-davinci/board-dm644x-evm.c   
 |4 +-
 arch/arm/mach-davinci/davinci.h
 |   11 +-
 arch/arm/mach-davinci/dm355.c  
 |  174 +-
 arch/arm/mach-davinci/dm365.c  
 |  195 ++-
 arch/arm/mach-davinci/dm644x.c 
 |9 +-
 arch/arm/mach-davinci/pm_domain.c  
 |2 +-
 

Re: [PATCH v8 0/7] V4L2 clock and async patches and soc-camera example

2013-04-12 Thread Sylwester Nawrocki
Hi Guennadi,

On 04/12/2013 08:13 AM, Guennadi Liakhovetski wrote:
 On Thu, 11 Apr 2013, Sylwester Nawrocki wrote:
 On 04/11/2013 11:59 AM, Guennadi Liakhovetski wrote:
 On Mon, 8 Apr 2013, Guennadi Liakhovetski wrote:

  Mostly just a re-spin of v7 with minor modifications.

  Guennadi Liakhovetski (7):
 media: V4L2: add temporary clock helpers
 media: V4L2: support asynchronous subdevice registration
 media: soc-camera: switch I2C subdevice drivers to use v4l2-clk
 soc-camera: add V4L2-async support
 sh_mobile_ceu_camera: add asynchronous subdevice probing support
 imx074: support asynchronous probing
 ARM: shmobile: convert ap4evb to asynchronously register camera
   subdevices

 So far there haven't been any comments to this, and Mauro asked to push
 all non-fixes to him by tomorrow. So, if at least the API is now ok, we
 could push this to 3.10, at least the core patches 1 and 2. Then during
 3.10 we could look at porting individual drivers on top of this.

 This patch series has significantly improved over time but I'm not sure
 it is all ready to merge it at this moment. At least it doesn't make sense
 to me to merge it without any users.
 
 I wouldn't be too scared to also push my soc-camera patches from the same 
 patch-series. But our V4L2 OF patches don't have many users so far either, 
 right? And they aren't likely to get any until asynchronous probing is 
 supported.

Arguably there is not many users, only Samsung H/W - couple drivers and boards.
I didn't push patches for the sensors that add device tree support, and are
moving any H/W access to the subdev's .registered callback. Since it is not
preferred way as we all agreed. But since I needed to focus on the Exynos ISP
driver I chose this method as an interim solution. In fact it works well 
without many changes in original initialization sequence that need to be 
carefully verified. 

Anyway, my plan is to focus more on the asynchronous registration stuff to 
possibly have it ready for 3.11. Now when the Exynos camera subsystem is still 
supported after this platform becomes dt-only. 

 The purpose of an introduction of this whole asynchronous probing concept
 was to add support for the device tree based systems. However there is no
 patch in this series that would be adding device tree support to some V4L2
 driver. That's a minor issue though I think.
 
 It is indeed. And I did have such patches in the past, but I dropped them 
 on purpose for now. It was too much work to update them all for each 
 iteration, so, I picked up a testable minimum.

Fair enough.

 A significant blocking point IMHO is that this API is bound to the circular
 dependency issue between a sub-device and the host driver. I think we should
 have at least some specific ideas on how to resolve it before pushing the
 API upstream. Or are there any already ?
 
 Of course there is at least one. I wouldn't propose (soc-camera) patches, 
 that lock modules hard into memory, once probing is complete.

Alright then, maybe I should have more carefully analysed you last patch
series. 

 One of the ideas I had was to make a sub-device driver drop the reference
 it has to the clock provider module (the host) as soon as it gets registered
 to it. But it doesn't seem straightforward with the common clock API.
 
 It isn't.
 
 Other option is a sysfs attribute at a host driver that would allow to
 release its sub-device(s). But it sounds a bit strange to me to require
 userspace to touch some sysfs attributes before being able to remove some
 modules.

 Something probably needs to be changed at the high level design to avoid
 this circular dependency.
 
 Here's what I do in my soc-camera patches atm: holding a reference to a 
 (V4L2) clock doesn't increment bridge driver's use-count (for this 
 discussion I describe the combined soc-camera host and soc-camera core 
 functionality as a bridge driver, because that's what most non soc-camera 
 drivers will look like). So, it can be unloaded. Once unloaded, it 
 unregisters its V4L2 async notifier. Inside that the v4l2-async framework 
 first detaches the subdevice driver, then calls the notifier's .unbind() 
 method, which should now unregister the clock. Then, back in 
 v4l2_async_notifier_unregister() the subdevice driver is re-probed, this 
 time with no clock available, so, it re-enters the deferred probing state.

Ok, it looks better than I thought initially.. :)

Still, aren't there races possible, when the host driver gets unregistered
while subdev holds a reference to the clock, and before it gets registered
to the host ? The likelihood of that seems very low, but I fail to find
any prove it can't happen either.

 BTW, a bit of self-advertisement: most soc-camera host drivers will hardly 
 need any modifications to support asynchronous subdevice probing. It's all 
 hidden in the soc-camera core. The sh-mobile CEU driver had to be modified 
 because it supports one more subdevice - a CSI-2 

[REVIEW PATCH] bttv: Add Adlink MPG24 entry to the bttv cardlist

2013-04-12 Thread Hans Verkuil
Add a proper card entry for this device, rather than abusing entries that are
not-quite-right.

Regards,

Hans

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/CARDLIST.bttv |1 +
 drivers/media/pci/bt8xx/bttv-cards.c|   22 +-
 drivers/media/pci/bt8xx/bttv.h  |1 +
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/Documentation/video4linux/CARDLIST.bttv 
b/Documentation/video4linux/CARDLIST.bttv
index 581f666..407ab46 100644
--- a/Documentation/video4linux/CARDLIST.bttv
+++ b/Documentation/video4linux/CARDLIST.bttv
@@ -160,3 +160,4 @@
 159 - ProVideo PV183  
[1830:1540,1831:1540,1832:1540,1833:1540,1834:1540,1835:1540,1836:1540,1837:1540]
 160 - Tongwei Video Technology TD-3116[f200:3116]
 161 - Aposonic W-DVR  [0279:0228]
+162 - Adlink MPG24
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c 
b/drivers/media/pci/bt8xx/bttv-cards.c
index b7dc921..8d327ff 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -2705,7 +2705,7 @@ struct tvcard bttv_tvcards[] = {
.has_radio  = 1,
.has_remote = 1,
},
-   [BTTV_BOARD_VD012] = {
+   [BTTV_BOARD_VD012] = {
/* d.h...@phytec.de */
.name   = PHYTEC VD-012 (bt878),
.video_inputs   = 4,
@@ -2718,7 +2718,7 @@ struct tvcard bttv_tvcards[] = {
.tuner_type = TUNER_ABSENT,
.tuner_addr = ADDR_UNSET,
},
-   [BTTV_BOARD_VD012_X1] = {
+   [BTTV_BOARD_VD012_X1] = {
/* d.h...@phytec.de */
.name   = PHYTEC VD-012-X1 (bt878),
.video_inputs   = 4,
@@ -2731,7 +2731,7 @@ struct tvcard bttv_tvcards[] = {
.tuner_type = TUNER_ABSENT,
.tuner_addr = ADDR_UNSET,
},
-   [BTTV_BOARD_VD012_X2] = {
+   [BTTV_BOARD_VD012_X2] = {
/* d.h...@phytec.de */
.name   = PHYTEC VD-012-X2 (bt878),
.video_inputs   = 4,
@@ -2744,7 +2744,7 @@ struct tvcard bttv_tvcards[] = {
.tuner_type = TUNER_ABSENT,
.tuner_addr = ADDR_UNSET,
},
-   [BTTV_BOARD_GEOVISION_GV800S] = {
+   [BTTV_BOARD_GEOVISION_GV800S] = {
/* Bruno Christo bchri...@inf.ufsm.br
 *
 * GeoVision GV-800(S) has 4 Conexant Fusion 878A:
@@ -2771,7 +2771,7 @@ struct tvcard bttv_tvcards[] = {
.no_tda7432 = 1,
.muxsel_hook= gv800s_muxsel,
},
-   [BTTV_BOARD_GEOVISION_GV800S_SL] = {
+   [BTTV_BOARD_GEOVISION_GV800S_SL] = {
/* Bruno Christo bchri...@inf.ufsm.br
 *
 * GeoVision GV-800(S) has 4 Conexant Fusion 878A:
@@ -2808,6 +2808,7 @@ struct tvcard bttv_tvcards[] = {
.tuner_type = TUNER_ABSENT,
.tuner_addr = ADDR_UNSET,
},
+   /*  card 0xa0-- */
[BTTV_BOARD_TVT_TD3116] = {
.name   = Tongwei Video Technology TD-3116,
.video_inputs   = 16,
@@ -2825,6 +2826,17 @@ struct tvcard bttv_tvcards[] = {
.muxsel = MUXSEL(2, 3, 1, 0),
.tuner_type = TUNER_ABSENT,
},
+   [BTTV_BOARD_ADLINK_MPG24] = {
+   /* Adlink MPG24 */
+   .name   = Adlink MPG24,
+   .video_inputs   = 1,
+   /* .audio_inputs= 1, */
+   .svhs   = NO_SVHS,
+   .muxsel = MUXSEL(2, 2, 2, 2),
+   .tuner_type = UNSET,
+   .tuner_addr = ADDR_UNSET,
+   .pll= PLL_28,
+   },
 
 };
 
diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h
index 6139ce2..f01c9d4 100644
--- a/drivers/media/pci/bt8xx/bttv.h
+++ b/drivers/media/pci/bt8xx/bttv.h
@@ -185,6 +185,7 @@
 #define BTTV_BOARD_PV183   0x9f
 #define BTTV_BOARD_TVT_TD3116 0xa0
 #define BTTV_BOARD_APOSONIC_WDVR   0xa1
+#define BTTV_BOARD_ADLINK_MPG240xa2
 
 /* more card-specific defines */
 #define PT2254_L_CHANNEL 0x10
-- 
1.7.10.4

--
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: Delock 61959

2013-04-12 Thread Jakob Haufe
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tue, 9 Apr 2013 14:48:05 +0200
Jakob Haufe su...@sur5r.net wrote:

 Will do so tonight and report back.

Took a little longer but it worked as expected. Patch follows in a separate
mail.

dmesg output:

[19.474818] em28xx: New device  USB 2875 Device @ 480 Mbps (1b80:e1cc, 
interface 0, class 0)
[19.484245] em28xx: DVB interface 0 found: isoc
[19.493626] em28xx: chip ID is em2874
[19.771843] em2874 #0: i2c eeprom : 26 00 01 00 02 08 c8 e5 f5 64 01 60 09 
e5 f5 64
[19.781820] em2874 #0: i2c eeprom 0010: 09 60 03 c2 c6 22 e5 f7 b4 03 13 e5 f6 
b4 87 03
[19.791682] em2874 #0: i2c eeprom 0020: 02 08 63 e5 f6 b4 93 03 02 06 f7 c2 c6 
22 c2 c6
[19.801429] em2874 #0: i2c eeprom 0030: 22 00 60 00 90 00 60 12 06 29 7b 95 7a 
67 79 eb
[19.810955] em2874 #0: i2c eeprom 0040: 78 1a c3 12 06 18 70 03 d3 80 01 c3 92 
02 90 78
[19.820345] em2874 #0: i2c eeprom 0050: 0b 74 96 f0 74 82 f0 90 78 5d 74 05 f0 
a3 f0 22
[19.829532] em2874 #0: i2c eeprom 0060: 00 00 00 00 1a eb 67 95 80 1b cc e1 f0 
93 6b 00
[19.838768] em2874 #0: i2c eeprom 0070: 6a 20 00 00 00 00 04 57 4e 07 09 00 00 
00 00 00
[19.848037] em2874 #0: i2c eeprom 0080: 00 00 00 00 4e 00 12 00 f0 10 44 89 88 
00 00 00
[19.857240] em2874 #0: i2c eeprom 0090: 5b 81 c0 00 00 00 20 40 20 80 02 20 01 
01 00 00
[19.866452] em2874 #0: i2c eeprom 00a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00
[19.875663] em2874 #0: i2c eeprom 00b0: c6 40 00 00 00 00 87 00 00 00 00 00 00 
40 00 00
[19.884863] em2874 #0: i2c eeprom 00c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 20 03
[19.894000] em2874 #0: i2c eeprom 00d0: 55 00 53 00 42 00 20 00 32 00 38 00 37 
00 35 00
[19.903174] em2874 #0: i2c eeprom 00e0: 20 00 44 00 65 00 76 00 69 00 63 00 65 
00 04 03
[19.912282] em2874 #0: i2c eeprom 00f0: 31 00 00 00 33 00 34 00 35 00 36 00 37 
00 38 00
[19.921329] em2874 #0: i2c eeprom 0100: ... (skipped)
[19.930134] em2874 #0: EEPROM ID = 26 00 01 00, EEPROM hash = 0xde1f879b
[19.938967] em2874 #0: EEPROM info:
[19.947590] em2874 #0:   microcode start address = 0x0004, boot 
configuration = 0x01
[19.964171] em2874 #0:   No audio on board.
[19.972548] em2874 #0:   500mA max power
[19.980912] em2874 #0:   Table at offset 0x00, strings=0x, 0x, 
0x
[19.989859] em2874 #0: Identified as MaxMedia UB425-TC (card=84)
[19.998518] em2874 #0: v4l2 driver version 0.2.0
[20.012548] em2874 #0: V4L2 video device registered as video0
[20.021268] em2874 #0: dvb set to isoc mode.
[20.02] drxk: status = 0x439130d9
[20.075896] drxk: detected a drx-3913k, spin A2, xtal 20.250 MHz
[20.158282] DRXK driver version 0.9.4300
[20.184878] drxk: frontend initialized.
[22.025707] em2874 #0: MaxMedia UB425-TC: only DVB-C supported by that driver 
version
[22.035149] DVB: registering new adapter (em2874 #0)
[22.044967] usb 1-1: DVB: registering adapter 0 frontend 0 (DRXK DVB-C DVB-T)...
[22.061012] em2874 #0: Successfully loaded em28xx-dvb

I then ran tvheadend for a couple of hours and it worked without problems.

I'm just wondering how to get the IR remote to work. As the UB425-TC comes
with a remote as well I kind of expected that the codes will be the same.

Would trying different values for .ir_codes make sense or is there some other
way to find this out?

Cheers,
Jakob

- -- 
ceterum censeo microsoftem esse delendam.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlFoF3gACgkQ1YAhDic+adZ1BQCeJbr86AncHGM+Rw2rwuDiDDDi
0qAAoIHdhZYoYxCP6fPWlfO8aH0rIC3U
=dIxP
-END PGP SIGNATURE-


[PATCH] Add support for Delock 61959

2013-04-12 Thread Jakob Haufe
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Delock 61959 seems to be a relabeled version of Maxmedia UB425-TC with a
different USB ID. PCB is marked as UB425-TC Ver: A and this change
makes it work without any obvious problems.

Signed-off-by: Jakob Haufe su...@sur5r.net
- ---
 drivers/media/usb/em28xx/em28xx-cards.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 1d3866f..82950aa 100644
- --- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -2173,6 +2173,8 @@ struct usb_device_id em28xx_id_table[] = {
.driver_info = EM2860_BOARD_EASYCAP },
{ USB_DEVICE(0x1b80, 0xe425),
.driver_info = EM2874_BOARD_MAXMEDIA_UB425_TC },
+   { USB_DEVICE(0x1b80, 0xe1cc), /* Delock 61959 */
+   .driver_info = EM2874_BOARD_MAXMEDIA_UB425_TC },
{ USB_DEVICE(0x2304, 0x0242),
.driver_info = EM2884_BOARD_PCTV_510E },
{ USB_DEVICE(0x2013, 0x0251),
- -- 
1.7.10.4


- -- 
ceterum censeo microsoftem esse delendam.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlFoF8AACgkQ1YAhDic+adaIPQCfZQ+6gUH/JA6N2QVsa7nrpZyL
vSsAn3e+zMiFiM80Vn1oTGrgnkhDxfcx
=mOcG
-END PGP SIGNATURE-


Re: [PATCH v8 2/7] media: V4L2: support asynchronous subdevice registration

2013-04-12 Thread Guennadi Liakhovetski
Hi Laurent

Thanks for the review.

On Fri, 12 Apr 2013, Laurent Pinchart wrote:

[snip]

  +   switch (hw-bus_type) {
  +   case V4L2_ASYNC_BUS_CUSTOM:
  +   match = hw-match.special.match;
  +   if (!match)
  +   /* Match always */
  +   return asd;
  +   break;
  +   case V4L2_ASYNC_BUS_PLATFORM:
  +   match = match_platform;
  +   break;
  +   case V4L2_ASYNC_BUS_I2C:
  +   match = match_i2c;
  +   break;
  +   default:
  +   /* Oops */
  +   match = NULL;
  +   dev_err(notifier-v4l2_dev ? notifier-v4l2_dev-dev : 
  NULL,
  +   Invalid bus-type %u on %p\n, hw-bus_type, 
  asd);
 
 An invalid hw-bus_type value is a driver (or board code) bug. Could you move 
 this check to v4l2_async_notifier_register() when building the subdev list 
 and 
 return an error ?

agree.

  +static struct device *v4l2_async_unregister(struct v4l2_async_subdev_list
  *asdl)
  +{
  +   struct device *dev = asdl-dev;
  +
  +   v4l2_async_cleanup(asdl);
  +
  +   /* If we handled USB devices, we'd have to lock the parent too */
  +   device_release_driver(dev);
  +   return dev;
 
 This function is called from a single location and the return value is 
 unused, 
 it could just return void.

will be changed

  +}
  +
  +int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
  +struct v4l2_async_notifier *notifier)
  +{
  +   struct v4l2_async_subdev_list *asdl, *tmp;
  +   int i;
 
 Could this be unsigned (please see below for a similar comment about notifier-
 subdev_num as well) ?

I like it how clearly we can separate in our reviews suggestions for 
technical quality improvements from personal opinions and preferences ;-)

  +void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
  +{
  +   struct v4l2_async_subdev_list *asdl, *tmp;
  +   int i = 0;
 
 i can't be negative, could it then be unsiged ?

Ditto :)

  +   struct device **dev = kcalloc(notifier-subdev_num,
  + sizeof(*dev), GFP_KERNEL);
  +   if (!dev)
  +   dev_err(notifier-v4l2_dev-dev,
  +   Failed to allocate device cache!\n);
  +
  +   mutex_lock(list_lock);
  +
  +   list_del(notifier-list);
  +
  +   list_for_each_entry_safe(asdl, tmp, notifier-done, list) {
  +   if (dev)
  +   dev[i++] = get_device(asdl-dev);
  +   v4l2_async_unregister(asdl);
  +
  +   if (notifier-unbind)
  +   notifier-unbind(notifier, asdl);
  +   }
  +
  +   mutex_unlock(list_lock);
  +
  +   if (dev) {
  +   while (i--) {
  +   if (dev[i]  device_attach(dev[i])  0)
 
 I'm still pretty uneasy about the device_attach() and device_release_driver() 
 calls, I'll read your reply to Sylwester's comments and I'll answer there.

Maybe the following will help: we also discussed this with Greg K-H, he 
also initially was of the opinion, that these calls shouldn't be needed in 
_device_ drivers. They are to be used by bus drivers. Then I explained, 
that we are indeed dealing with a media bus here. He didn't reply any 
more :-)

  +struct v4l2_async_hw_device {
  +   enum v4l2_async_bus_type bus_type;
  +   union {
  +   struct {
  +   const char *name;
  +   } platform;
  +   struct {
  +   int adapter_id;
  +   unsigned short address;
  +   } i2c;
 
 Do you think it would make sense to match I2C devices by name as well (using 
 dev_name(dev)) ?

not necessarily... it would make it uniform, yes, but code authors would 
have to hard-code device names, that are otherwise created by the I2C core. 
Are we sure those never change? Don't think we're supposed to rely on them.

  +   struct {
  +   bool (*match)(struct device *,
  + struct v4l2_async_hw_device *);
  +   void *priv;
  +   } special;
  +   } match;
  +};
 
 This isn't really a device, what about renaming it to v4l2_async_device_info, 
 v4l2_async_hw_info, v4l2_async_dev_info, ... (or s/info/desc/) ?

ok

  +/**
  + * struct v4l2_async_subdev - sub-device descriptor, as known to a bridge
  + * @hw:this device descriptor
  + * @list:  member in a list of subdevices
  + */
  +struct v4l2_async_subdev {
  +   struct v4l2_async_hw_device hw;
  +   struct list_head list;
  +};
 
 I was wondering whether this structure couldn't be made private (and thus 
 dynamically allocated), but that might be overkill.

seems an overkill to me too.

 The structure isn't not part of the public API, except to access the hw 
 field. 
 Maybe the bound and unbind notifiers could get a pointer to the hw field 
 directly to avoid going 

Re: [PATCH] Add support for Delock 61959

2013-04-12 Thread Antti Palosaari

On 04/12/2013 05:18 PM, Jakob Haufe wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Delock 61959 seems to be a relabeled version of Maxmedia UB425-TC with a
different USB ID. PCB is marked as UB425-TC Ver: A and this change
makes it work without any obvious problems.

Signed-off-by: Jakob Haufe su...@sur5r.net


Acked-by: Antti Palosaari cr...@iki.fi
Reviewed-by: Antti Palosaari cr...@iki.fi


- ---
  drivers/media/usb/em28xx/em28xx-cards.c |2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 1d3866f..82950aa 100644
- --- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -2173,6 +2173,8 @@ struct usb_device_id em28xx_id_table[] = {
 .driver_info = EM2860_BOARD_EASYCAP },
 { USB_DEVICE(0x1b80, 0xe425),
 .driver_info = EM2874_BOARD_MAXMEDIA_UB425_TC },
+   { USB_DEVICE(0x1b80, 0xe1cc), /* Delock 61959 */
+   .driver_info = EM2874_BOARD_MAXMEDIA_UB425_TC },
 { USB_DEVICE(0x2304, 0x0242),
 .driver_info = EM2884_BOARD_PCTV_510E },
 { USB_DEVICE(0x2013, 0x0251),
- --
1.7.10.4


- --
ceterum censeo microsoftem esse delendam.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlFoF8AACgkQ1YAhDic+adaIPQCfZQ+6gUH/JA6N2QVsa7nrpZyL
vSsAn3e+zMiFiM80Vn1oTGrgnkhDxfcx
=mOcG
-END PGP SIGNATURE-
N‹§²æìr¸›yúèšØb²X¬¶Ç§vØ^–)Þº{.nÇ+‰·¥Š{±™çbj)í…æèw*jg¬±¨¶‰šŽŠÝ¢j/�êäz¹Þ–Šà2ŠÞ™¨è­Ú¢)ß¡«a¶Úþø®G«�éh®æj:+v‰¨Šwè†Ù¥




--
http://palosaari.fi/
--
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: Delock 61959

2013-04-12 Thread Antti Palosaari

On 04/12/2013 05:17 PM, Jakob Haufe wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tue, 9 Apr 2013 14:48:05 +0200
Jakob Haufe su...@sur5r.net wrote:


Will do so tonight and report back.


Took a little longer but it worked as expected. Patch follows in a separate
mail.

dmesg output:

[19.474818] em28xx: New device  USB 2875 Device @ 480 Mbps (1b80:e1cc, 
interface 0, class 0)
[19.484245] em28xx: DVB interface 0 found: isoc
[19.493626] em28xx: chip ID is em2874
[19.771843] em2874 #0: i2c eeprom : 26 00 01 00 02 08 c8 e5 f5 64 01 60 09 
e5 f5 64
[19.781820] em2874 #0: i2c eeprom 0010: 09 60 03 c2 c6 22 e5 f7 b4 03 13 e5 f6 
b4 87 03
[19.791682] em2874 #0: i2c eeprom 0020: 02 08 63 e5 f6 b4 93 03 02 06 f7 c2 c6 
22 c2 c6
[19.801429] em2874 #0: i2c eeprom 0030: 22 00 60 00 90 00 60 12 06 29 7b 95 7a 
67 79 eb
[19.810955] em2874 #0: i2c eeprom 0040: 78 1a c3 12 06 18 70 03 d3 80 01 c3 92 
02 90 78
[19.820345] em2874 #0: i2c eeprom 0050: 0b 74 96 f0 74 82 f0 90 78 5d 74 05 f0 
a3 f0 22
[19.829532] em2874 #0: i2c eeprom 0060: 00 00 00 00 1a eb 67 95 80 1b cc e1 f0 
93 6b 00
[19.838768] em2874 #0: i2c eeprom 0070: 6a 20 00 00 00 00 04 57 4e 07 09 00 00 
00 00 00
[19.848037] em2874 #0: i2c eeprom 0080: 00 00 00 00 4e 00 12 00 f0 10 44 89 88 
00 00 00
[19.857240] em2874 #0: i2c eeprom 0090: 5b 81 c0 00 00 00 20 40 20 80 02 20 01 
01 00 00
[19.866452] em2874 #0: i2c eeprom 00a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00
[19.875663] em2874 #0: i2c eeprom 00b0: c6 40 00 00 00 00 87 00 00 00 00 00 00 
40 00 00
[19.884863] em2874 #0: i2c eeprom 00c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 20 03
[19.894000] em2874 #0: i2c eeprom 00d0: 55 00 53 00 42 00 20 00 32 00 38 00 37 
00 35 00
[19.903174] em2874 #0: i2c eeprom 00e0: 20 00 44 00 65 00 76 00 69 00 63 00 65 
00 04 03
[19.912282] em2874 #0: i2c eeprom 00f0: 31 00 00 00 33 00 34 00 35 00 36 00 37 
00 38 00
[19.921329] em2874 #0: i2c eeprom 0100: ... (skipped)
[19.930134] em2874 #0: EEPROM ID = 26 00 01 00, EEPROM hash = 0xde1f879b
[19.938967] em2874 #0: EEPROM info:
[19.947590] em2874 #0:   microcode start address = 0x0004, boot 
configuration = 0x01
[19.964171] em2874 #0:   No audio on board.
[19.972548] em2874 #0:   500mA max power
[19.980912] em2874 #0:   Table at offset 0x00, strings=0x, 0x, 
0x
[19.989859] em2874 #0: Identified as MaxMedia UB425-TC (card=84)
[19.998518] em2874 #0: v4l2 driver version 0.2.0
[20.012548] em2874 #0: V4L2 video device registered as video0
[20.021268] em2874 #0: dvb set to isoc mode.
[20.02] drxk: status = 0x439130d9
[20.075896] drxk: detected a drx-3913k, spin A2, xtal 20.250 MHz
[20.158282] DRXK driver version 0.9.4300
[20.184878] drxk: frontend initialized.
[22.025707] em2874 #0: MaxMedia UB425-TC: only DVB-C supported by that driver 
version


IIRC you mentioned (on IRC?) it works well for DVB-T too? In that case 
there is likely newer DRX-K chip (with newer inbuild firmware) than 
device I added that board originally. Anyhow, it is only that log 
printing so let it be...



[22.035149] DVB: registering new adapter (em2874 #0)
[22.044967] usb 1-1: DVB: registering adapter 0 frontend 0 (DRXK DVB-C DVB-T)...
[22.061012] em2874 #0: Successfully loaded em28xx-dvb

I then ran tvheadend for a couple of hours and it worked without problems.

I'm just wondering how to get the IR remote to work. As the UB425-TC comes
with a remote as well I kind of expected that the codes will be the same.


I didn't add remote keytable as I was lazy at the time.

Here is pictures from my device, look if it is similar.
https://plus.google.com/photos/117997283802118441421/albums/5721245288768209697


Would trying different values for .ir_codes make sense or is there some other
way to find this out?


Use em28xx ir debug to dump raw codes. Then look all existing remote 
keytables if there is already correct table.


regards
Antti


--
http://palosaari.fi/
--
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


[RFC] Motion Detection API

2013-04-12 Thread Hans Verkuil
This RFC looks at adding support for motion detection to V4L2. This is the main
missing piece that prevents the go7007 and solo6x10 drivers from being moved
into mainline from the staging directory.

Step one is to look at existing drivers/hardware:

1) The go7007 driver:

- divides the frame into blocks of 16x16 pixels each (that's 45x36 
blocks for PAL)
- each block can be assigned to region 0, 1, 2 or 3
- each region has:
- a pixel change threshold
- a motion vector change threshold
- a trigger level; if this is 0, then motion detection for this
  region is disabled
- when streaming the reserved field of v4l2_buffer is used as a bitmask:
  one bit for each region where motion is detected.

2) The solo6x10 driver:

- divides the frame into blocks of 16x16 pixels each
- each block has its own threshold
- the driver adds one MOTION_ON buffer flag and one MOTION_DETECTED 
buffer
  flag.
- motion detection can be disabled or enabled.
- the driver has a global motion detection mode with just one threshold:
  in that case all blocks are set to the same threshold.
- there is also support for displaying a border around the image if 
motion
  is detected (very hardware specific).

3) The tw2804 video encoder (based on the datasheet, not implemented in the 
driver):

- divides the image in 12x12 blocks (block size will differ for NTSC vs 
PAL)
- motion detection can be enabled or disabled for each block
- there are four controls: 
- luminance level change threshold
- spatial sensitivity threshold
- temporal sensitivity threshold
- velocity control (determines how well slow motions are 
detected)
- detection is reported by a hardware pin in this case

Comparing these three examples of motion detection I see quite a lot of 
similarities,
enough to make a proposal for an API:

- Add a MOTION_DETECTION menu control:
- Disabled
- Global Motion Detection
- Regional Motion Detection

If 'Global Motion Detection' is selected, then various threshold controls become
available. What sort of thresholds are available seems to be quite variable, so
I am inclined to leave this as private controls.

- Add new buffer flags when motion is detected. The go7007 driver would need 4
  bits (one for each region), the others just one. This can be done by taking
  4 bits from the v4l2_buffer flags field. There are still 16 bits left there,
  and if it becomes full, then we still have two reserved fields. I see no
  reason for adding a 'MOTION_ON' flag as the solo6x10 driver does today: just
  check the MOTION_DETECTION control if you want to know if motion detection
  is on or not.

- Add two new ioctls to get and set the block data:

#define V4L2_MD_HOR_BLOCKS (64)
#define V4L2_MD_VERT_BLOCKS (48)

#define V4L2_MD_TYPE_REGION (1)
#define V4L2_MD_TYPE_THRESHOLD  (2)

struct v4l2_md_blocks {
__u32 type;
struct v4l2_rect rect;
__u32 minimum;
__u32 maximum;
__u32 reserved[32];
__u16 blocks[V4L2_MD_HOR_BLOCKS][V4L2_MD_VERT_BLOCKS];
};

#define VIDIOC_G_MD_BLOCKS_IORW('V', 103, struct v4l2_md_blocks)
#define VIDIOC_S_MD_BLOCKS_IORW('V', 104, struct v4l2_md_blocks)

  Apps must fill in type, then can call G_MD_BLOCKS to get the current block
  values for that type. TYPE_REGION returns to which region each block belongs,
  TYPE_THRESHOLD returns threshold values for each block.

  rect returns the rectangle of valid blocks, minimum and maximum the min and 
max
  values for each 'blocks' array element.

  To change the blocks apps call S_MD_BLOCKS, fill in type, rect (rect is useful
  here to set only a subset of all blocks) and blocks.

So the go7007 would return 45x36 in rect, type would be REGION, min/max would be
0-3.

solo6x10 would return 45x36 in rect, type would be THRESHOLD, min/max would be
0-65535.

TW2804 would return 12x12 in rect, type would be THRESHOLD, min/max would be 
0-1.

Comment? Questions?

Regards,

Hans
--
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 v9 10/20] mx1-camera: move interface activation and deactivation to clock callbacks

2013-04-12 Thread Guennadi Liakhovetski
When adding and removing a client, the mx1-camera driver only activates
and deactivates its camera interface respectively, which doesn't include
any client-specific actions. Move this functionality into .clock_start()
and .clock_stop() callbacks.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/mx1_camera.c |   32 +++-
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/soc_camera/mx1_camera.c 
b/drivers/media/platform/soc_camera/mx1_camera.c
index 5f9ec8e..fea3e61 100644
--- a/drivers/media/platform/soc_camera/mx1_camera.c
+++ b/drivers/media/platform/soc_camera/mx1_camera.c
@@ -399,7 +399,7 @@ static void mx1_camera_activate(struct mx1_camera_dev 
*pcdev)
 {
unsigned int csicr1 = CSICR1_EN;
 
-   dev_dbg(pcdev-soc_host.icd-parent, Activate device\n);
+   dev_dbg(pcdev-soc_host.v4l2_dev.dev, Activate device\n);
 
clk_prepare_enable(pcdev-clk);
 
@@ -415,7 +415,7 @@ static void mx1_camera_activate(struct mx1_camera_dev 
*pcdev)
 
 static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
 {
-   dev_dbg(pcdev-soc_host.icd-parent, Deactivate device\n);
+   dev_dbg(pcdev-soc_host.v4l2_dev.dev, Deactivate device\n);
 
/* Disable all CSI interface */
__raw_writel(0x00, pcdev-base + CSICR1);
@@ -423,26 +423,35 @@ static void mx1_camera_deactivate(struct mx1_camera_dev 
*pcdev)
clk_disable_unprepare(pcdev-clk);
 }
 
+static int mx1_camera_add_device(struct soc_camera_device *icd)
+{
+   dev_info(icd-parent, MX1 Camera driver attached to camera %d\n,
+icd-devnum);
+
+   return 0;
+}
+
+static void mx1_camera_remove_device(struct soc_camera_device *icd)
+{
+   dev_info(icd-parent, MX1 Camera driver detached from camera %d\n,
+icd-devnum);
+}
+
 /*
  * The following two functions absolutely depend on the fact, that
  * there can be only one camera on i.MX1/i.MXL camera sensor interface
  */
-static int mx1_camera_add_device(struct soc_camera_device *icd)
+static int mx1_camera_clock_start(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct mx1_camera_dev *pcdev = ici-priv;
 
-   dev_info(icd-parent, MX1 Camera driver attached to camera %d\n,
-icd-devnum);
-
mx1_camera_activate(pcdev);
 
return 0;
 }
 
-static void mx1_camera_remove_device(struct soc_camera_device *icd)
+static void mx1_camera_clock_stop(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct mx1_camera_dev *pcdev = ici-priv;
unsigned int csicr1;
 
@@ -453,9 +462,6 @@ static void mx1_camera_remove_device(struct 
soc_camera_device *icd)
/* Stop DMA engine */
imx_dma_disable(pcdev-dma_chan);
 
-   dev_info(icd-parent, MX1 Camera driver detached from camera %d\n,
-icd-devnum);
-
mx1_camera_deactivate(pcdev);
 }
 
@@ -669,6 +675,8 @@ static struct soc_camera_host_ops mx1_soc_camera_host_ops = 
{
.owner  = THIS_MODULE,
.add= mx1_camera_add_device,
.remove = mx1_camera_remove_device,
+   .clock_start= mx1_camera_clock_start,
+   .clock_stop = mx1_camera_clock_stop,
.set_bus_param  = mx1_camera_set_bus_param,
.set_fmt= mx1_camera_set_fmt,
.try_fmt= mx1_camera_try_fmt,
-- 
1.7.2.5

--
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 v9 08/20] mx3-camera: move interface activation and deactivation to clock callbacks

2013-04-12 Thread Guennadi Liakhovetski
When adding and removing a client, the mx3-camera driver only activates
and deactivates its camera interface respectively, which doesn't include
any client-specific actions. Move this functionality into .clock_start()
and .clock_stop() callbacks.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/mx3_camera.c |   35 ++-
 1 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/soc_camera/mx3_camera.c 
b/drivers/media/platform/soc_camera/mx3_camera.c
index 71b9b19..1047e3e 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/media/platform/soc_camera/mx3_camera.c
@@ -460,8 +460,7 @@ static int mx3_camera_init_videobuf(struct vb2_queue *q,
 }
 
 /* First part of ipu_csi_init_interface() */
-static void mx3_camera_activate(struct mx3_camera_dev *mx3_cam,
-   struct soc_camera_device *icd)
+static void mx3_camera_activate(struct mx3_camera_dev *mx3_cam)
 {
u32 conf;
long rate;
@@ -505,31 +504,40 @@ static void mx3_camera_activate(struct mx3_camera_dev 
*mx3_cam,
 
clk_prepare_enable(mx3_cam-clk);
rate = clk_round_rate(mx3_cam-clk, mx3_cam-mclk);
-   dev_dbg(icd-parent, Set SENS_CONF to %x, rate %ld\n, conf, rate);
+   dev_dbg(mx3_cam-soc_host.v4l2_dev.dev, Set SENS_CONF to %x, rate 
%ld\n, conf, rate);
if (rate)
clk_set_rate(mx3_cam-clk, rate);
 }
 
-/* Called with .host_lock held */
 static int mx3_camera_add_device(struct soc_camera_device *icd)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
+   dev_info(icd-parent, MX3 Camera driver attached to camera %d\n,
+icd-devnum);
+
+   return 0;
+}
+
+static void mx3_camera_remove_device(struct soc_camera_device *icd)
+{
+   dev_info(icd-parent, MX3 Camera driver detached from camera %d\n,
+icd-devnum);
+}
+
+/* Called with .host_lock held */
+static int mx3_camera_clock_start(struct soc_camera_host *ici)
+{
struct mx3_camera_dev *mx3_cam = ici-priv;
 
-   mx3_camera_activate(mx3_cam, icd);
+   mx3_camera_activate(mx3_cam);
 
mx3_cam-buf_total = 0;
 
-   dev_info(icd-parent, MX3 Camera driver attached to camera %d\n,
-icd-devnum);
-
return 0;
 }
 
 /* Called with .host_lock held */
-static void mx3_camera_remove_device(struct soc_camera_device *icd)
+static void mx3_camera_clock_stop(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct mx3_camera_dev *mx3_cam = ici-priv;
struct idmac_channel **ichan = mx3_cam-idmac_channel[0];
 
@@ -539,9 +547,6 @@ static void mx3_camera_remove_device(struct 
soc_camera_device *icd)
}
 
clk_disable_unprepare(mx3_cam-clk);
-
-   dev_info(icd-parent, MX3 Camera driver detached from camera %d\n,
-icd-devnum);
 }
 
 static int test_platform_param(struct mx3_camera_dev *mx3_cam,
@@ -1124,6 +1129,8 @@ static struct soc_camera_host_ops mx3_soc_camera_host_ops 
= {
.owner  = THIS_MODULE,
.add= mx3_camera_add_device,
.remove = mx3_camera_remove_device,
+   .clock_start= mx3_camera_clock_start,
+   .clock_stop = mx3_camera_clock_stop,
.set_crop   = mx3_camera_set_crop,
.set_fmt= mx3_camera_set_fmt,
.try_fmt= mx3_camera_try_fmt,
-- 
1.7.2.5

--
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 v9 20/20] ARM: shmobile: convert ap4evb to asynchronously register camera subdevices

2013-04-12 Thread Guennadi Liakhovetski
Register the imx074 camera I2C and the CSI-2 platform devices directly
in board platform data instead of letting the sh_mobile_ceu_camera driver
and the soc-camera framework register them at their run-time. This uses
the V4L2 asynchronous subdevice probing capability.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 arch/arm/mach-shmobile/board-ap4evb.c |  103 +++-
 arch/arm/mach-shmobile/clock-sh7372.c |1 +
 2 files changed, 62 insertions(+), 42 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-ap4evb.c 
b/arch/arm/mach-shmobile/board-ap4evb.c
index 38f1259..450e06b 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -50,6 +50,7 @@
 #include media/sh_mobile_ceu.h
 #include media/sh_mobile_csi2.h
 #include media/soc_camera.h
+#include media/v4l2-async.h
 
 #include sound/sh_fsi.h
 #include sound/simple_card.h
@@ -871,22 +872,32 @@ static struct platform_device leds_device = {
},
 };
 
-static struct i2c_board_info imx074_info = {
-   I2C_BOARD_INFO(imx074, 0x1a),
+/* I2C */
+static struct soc_camera_subdev_desc imx074_desc;
+static struct i2c_board_info i2c0_devices[] = {
+   {
+   I2C_BOARD_INFO(ak4643, 0x13),
+   }, {
+   I2C_BOARD_INFO(imx074, 0x1a),
+   .platform_data = imx074_desc,
+   },
 };
 
-static struct soc_camera_link imx074_link = {
-   .bus_id = 0,
-   .board_info = imx074_info,
-   .i2c_adapter_id = 0,
-   .module_name= imx074,
+static struct i2c_board_info i2c1_devices[] = {
+   {
+   I2C_BOARD_INFO(r2025sd, 0x32),
+   },
 };
 
-static struct platform_device ap4evb_camera = {
-   .name   = soc-camera-pdrv,
-   .id = 0,
-   .dev= {
-   .platform_data = imx074_link,
+static struct resource csi2_resources[] = {
+   {
+   .name   = CSI2,
+   .start  = 0xffc9,
+   .end= 0xffc90fff,
+   .flags  = IORESOURCE_MEM,
+   }, {
+   .start  = intcs_evt2irq(0x17a0),
+   .flags  = IORESOURCE_IRQ,
},
 };
 
@@ -895,7 +906,7 @@ static struct sh_csi2_client_config csi2_clients[] = {
.phy= SH_CSI2_PHY_MAIN,
.lanes  = 0,/* default: 2 lanes */
.channel= 0,
-   .pdev   = ap4evb_camera,
+   .name   = imx074,
},
 };
 
@@ -906,31 +917,50 @@ static struct sh_csi2_pdata csi2_info = {
.flags  = SH_CSI2_ECC | SH_CSI2_CRC,
 };
 
-static struct resource csi2_resources[] = {
-   [0] = {
-   .name   = CSI2,
-   .start  = 0xffc9,
-   .end= 0xffc90fff,
-   .flags  = IORESOURCE_MEM,
+static struct platform_device csi2_device = {
+   .name   = sh-mobile-csi2,
+   .id = 0,
+   .num_resources  = ARRAY_SIZE(csi2_resources),
+   .resource   = csi2_resources,
+   .dev= {
+   .platform_data = csi2_info,
},
-   [1] = {
-   .start  = intcs_evt2irq(0x17a0),
-   .flags  = IORESOURCE_IRQ,
+};
+
+static struct soc_camera_async_subdev csi2_sd = {
+   .asd.hw = {
+   .bus_type = V4L2_ASYNC_BUS_PLATFORM,
+   .match.platform.name = sh-mobile-csi2.0,
},
+   .role = SOCAM_SUBDEV_DATA_PROCESSOR,
 };
 
-static struct sh_mobile_ceu_companion csi2 = {
-   .id = 0,
-   .num_resources  = ARRAY_SIZE(csi2_resources),
-   .resource   = csi2_resources,
-   .platform_data  = csi2_info,
+static struct soc_camera_async_subdev imx074_sd = {
+   .asd.hw = {
+   .bus_type = V4L2_ASYNC_BUS_I2C,
+   .match.i2c = {
+   .adapter_id = 0,
+   .address = 0x1a,
+   },
+   },
+   .role = SOCAM_SUBDEV_DATA_SOURCE,
 };
 
+static struct v4l2_async_subdev *ceu_subdevs[] = {
+   /* Single 2-element group */
+   csi2_sd.asd,
+   imx074_sd.asd,
+};
+
+/* 0-terminated array of group-sizes */
+static int ceu_subdev_sizes[] = {ARRAY_SIZE(ceu_subdevs), 0};
+
 static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
.flags = SH_CEU_FLAG_USE_8BIT_BUS,
.max_width = 8188,
.max_height = 8188,
-   .csi2 = csi2,
+   .asd = ceu_subdevs,
+   .asd_sizes = ceu_subdev_sizes,
 };
 
 static struct resource ceu_resources[] = {
@@ -975,7 +1005,7 @@ static struct platform_device *ap4evb_devices[] __initdata 
= {
lcdc_device,
lcdc1_device,
ceu_device,
-   ap4evb_camera,
+   csi2_device,
meram_device,
 };
 
@@ -1070,19 +1100,6 @@ static struct i2c_board_info tsc_device = {
/*.irq is selected on ap4evb_init */
 };
 
-/* I2C */
-static struct i2c_board_info i2c0_devices[] = {
-   {
-   

[PATCH v9 05/20] pxa-camera: move interface activation and deactivation to clock callbacks

2013-04-12 Thread Guennadi Liakhovetski
When adding and removing a client, the pxa-camera driver only activates
and deactivates its camera interface respectively, which doesn't include
any client-specific actions. Move this functionality into .clock_start()
and .clock_stop() callbacks.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/pxa_camera.c |   28 +++
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c 
b/drivers/media/platform/soc_camera/pxa_camera.c
index 686edf7..d4df305 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -955,33 +955,39 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
return IRQ_HANDLED;
 }
 
+static int pxa_camera_add_device(struct soc_camera_device *icd)
+{
+   dev_info(icd-parent, PXA Camera driver attached to camera %d\n,
+icd-devnum);
+
+   return 0;
+}
+
+static void pxa_camera_remove_device(struct soc_camera_device *icd)
+{
+   dev_info(icd-parent, PXA Camera driver detached from camera %d\n,
+icd-devnum);
+}
+
 /*
  * The following two functions absolutely depend on the fact, that
  * there can be only one camera on PXA quick capture interface
  * Called with .host_lock held
  */
-static int pxa_camera_add_device(struct soc_camera_device *icd)
+static int pxa_camera_clock_start(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct pxa_camera_dev *pcdev = ici-priv;
 
pxa_camera_activate(pcdev);
 
-   dev_info(icd-parent, PXA Camera driver attached to camera %d\n,
-icd-devnum);
-
return 0;
 }
 
 /* Called with .host_lock held */
-static void pxa_camera_remove_device(struct soc_camera_device *icd)
+static void pxa_camera_clock_stop(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct pxa_camera_dev *pcdev = ici-priv;
 
-   dev_info(icd-parent, PXA Camera driver detached from camera %d\n,
-icd-devnum);
-
/* disable capture, disable interrupts */
__raw_writel(0x3ff, pcdev-base + CICR0);
 
@@ -1630,6 +1636,8 @@ static struct soc_camera_host_ops pxa_soc_camera_host_ops 
= {
.owner  = THIS_MODULE,
.add= pxa_camera_add_device,
.remove = pxa_camera_remove_device,
+   .clock_start= pxa_camera_clock_start,
+   .clock_stop = pxa_camera_clock_stop,
.set_crop   = pxa_camera_set_crop,
.get_formats= pxa_camera_get_formats,
.put_formats= pxa_camera_put_formats,
-- 
1.7.2.5

--
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 v9 11/20] sh-mobile-ceu-camera: move interface activation and deactivation to clock callbacks

2013-04-12 Thread Guennadi Liakhovetski
When adding and removing a client, the sh-mobile-ceu-camera driver activates
and, respectively, deactivates its camera interface and, if necessary, the
CSI2 controller. Only handling of the CSI2 interface is client-specific and
is only needed, when a data-exchange with the client is taking place. Move
the rest to .clock_start() and .clock_stop() callbacks.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 .../platform/soc_camera/sh_mobile_ceu_camera.c |   58 
 1 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c 
b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 5b7d8e1..9037472 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -162,7 +162,6 @@ static u32 ceu_read(struct sh_mobile_ceu_dev *priv, 
unsigned long reg_offs)
 static int sh_mobile_ceu_soft_reset(struct sh_mobile_ceu_dev *pcdev)
 {
int i, success = 0;
-   struct soc_camera_device *icd = pcdev-ici.icd;
 
ceu_write(pcdev, CAPSR, 1  16); /* reset */
 
@@ -186,7 +185,7 @@ static int sh_mobile_ceu_soft_reset(struct 
sh_mobile_ceu_dev *pcdev)
 
 
if (2 != success) {
-   dev_warn(icd-pdev, soft reset time out\n);
+   dev_warn(pcdev-ici.v4l2_dev.dev, soft reset time out\n);
return -EIO;
}
 
@@ -543,35 +542,21 @@ static struct v4l2_subdev *find_csi2(struct 
sh_mobile_ceu_dev *pcdev)
return NULL;
 }
 
-/* Called with .host_lock held */
 static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)
 {
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct sh_mobile_ceu_dev *pcdev = ici-priv;
-   struct v4l2_subdev *csi2_sd;
+   struct v4l2_subdev *csi2_sd = find_csi2(pcdev);
int ret;
 
-   dev_info(icd-parent,
-SuperH Mobile CEU driver attached to camera %d\n,
-icd-devnum);
-
-   pm_runtime_get_sync(ici-v4l2_dev.dev);
-
-   pcdev-buf_total = 0;
-
-   ret = sh_mobile_ceu_soft_reset(pcdev);
-
-   csi2_sd = find_csi2(pcdev);
if (csi2_sd) {
csi2_sd-grp_id = soc_camera_grp_id(icd);
v4l2_set_subdev_hostdata(csi2_sd, icd);
}
 
ret = v4l2_subdev_call(csi2_sd, core, s_power, 1);
-   if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV) {
-   pm_runtime_put(ici-v4l2_dev.dev);
+   if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV)
return ret;
-   }
 
/*
 * -ENODEV is special: either csi2_sd == NULL or the CSI-2 driver
@@ -580,19 +565,48 @@ static int sh_mobile_ceu_add_device(struct 
soc_camera_device *icd)
if (ret == -ENODEV  csi2_sd)
csi2_sd-grp_id = 0;
 
+   dev_info(icd-parent,
+SuperH Mobile CEU driver attached to camera %d\n,
+icd-devnum);
+
return 0;
 }
 
-/* Called with .host_lock held */
 static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd)
 {
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct sh_mobile_ceu_dev *pcdev = ici-priv;
struct v4l2_subdev *csi2_sd = find_csi2(pcdev);
 
+   dev_info(icd-parent,
+SuperH Mobile CEU driver detached from camera %d\n,
+icd-devnum);
+
v4l2_subdev_call(csi2_sd, core, s_power, 0);
if (csi2_sd)
csi2_sd-grp_id = 0;
+}
+
+/* Called with .host_lock held */
+static int sh_mobile_ceu_clock_start(struct soc_camera_host *ici)
+{
+   struct sh_mobile_ceu_dev *pcdev = ici-priv;
+   int ret;
+
+   pm_runtime_get_sync(ici-v4l2_dev.dev);
+
+   pcdev-buf_total = 0;
+
+   ret = sh_mobile_ceu_soft_reset(pcdev);
+
+   return 0;
+}
+
+/* Called with .host_lock held */
+static void sh_mobile_ceu_clock_stop(struct soc_camera_host *ici)
+{
+   struct sh_mobile_ceu_dev *pcdev = ici-priv;
+
/* disable capture, disable interrupts */
ceu_write(pcdev, CEIER, 0);
sh_mobile_ceu_soft_reset(pcdev);
@@ -607,10 +621,6 @@ static void sh_mobile_ceu_remove_device(struct 
soc_camera_device *icd)
spin_unlock_irq(pcdev-lock);
 
pm_runtime_put(ici-v4l2_dev.dev);
-
-   dev_info(icd-parent,
-SuperH Mobile CEU driver detached from camera %d\n,
-icd-devnum);
 }
 
 /*
@@ -2027,6 +2037,8 @@ static struct soc_camera_host_ops sh_mobile_ceu_host_ops 
= {
.owner  = THIS_MODULE,
.add= sh_mobile_ceu_add_device,
.remove = sh_mobile_ceu_remove_device,
+   .clock_start= sh_mobile_ceu_clock_start,
+   .clock_stop = sh_mobile_ceu_clock_stop,
.get_formats= sh_mobile_ceu_get_formats,
.put_formats= sh_mobile_ceu_put_formats,
.get_crop   = sh_mobile_ceu_get_crop,
-- 
1.7.2.5

--
To unsubscribe 

[PATCH v9 06/20] omap1-camera: move interface activation and deactivation to clock callbacks

2013-04-12 Thread Guennadi Liakhovetski
When adding and removing a client, the omap1-camera driver only activates
and deactivates its camera interface respectively, which doesn't include
any client-specific actions. Move this functionality into .clock_start()
and .clock_stop() callbacks.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/omap1_camera.c |   27 ++---
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/soc_camera/omap1_camera.c 
b/drivers/media/platform/soc_camera/omap1_camera.c
index c42c23e..6769193 100644
--- a/drivers/media/platform/soc_camera/omap1_camera.c
+++ b/drivers/media/platform/soc_camera/omap1_camera.c
@@ -893,13 +893,26 @@ static void sensor_reset(struct omap1_cam_dev *pcdev, 
bool reset)
CAM_WRITE(pcdev, GPIO, !reset);
 }
 
+static int omap1_cam_add_device(struct soc_camera_device *icd)
+{
+   dev_dbg(icd-parent, OMAP1 Camera driver attached to camera %d\n,
+   icd-devnum);
+
+   return 0;
+}
+
+static void omap1_cam_remove_device(struct soc_camera_device *icd)
+{
+   dev_dbg(icd-parent,
+   OMAP1 Camera driver detached from camera %d\n, icd-devnum);
+}
+
 /*
  * The following two functions absolutely depend on the fact, that
  * there can be only one camera on OMAP1 camera sensor interface
  */
-static int omap1_cam_add_device(struct soc_camera_device *icd)
+static int omap1_cam_clock_start(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct omap1_cam_dev *pcdev = ici-priv;
u32 ctrlclock;
 
@@ -937,14 +950,11 @@ static int omap1_cam_add_device(struct soc_camera_device 
*icd)
 
sensor_reset(pcdev, false);
 
-   dev_dbg(icd-parent, OMAP1 Camera driver attached to camera %d\n,
-   icd-devnum);
return 0;
 }
 
-static void omap1_cam_remove_device(struct soc_camera_device *icd)
+static void omap1_cam_clock_stop(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct omap1_cam_dev *pcdev = ici-priv;
u32 ctrlclock;
 
@@ -965,9 +975,6 @@ static void omap1_cam_remove_device(struct 
soc_camera_device *icd)
CAM_WRITE(pcdev, CTRLCLOCK, ctrlclock  ~MCLK_EN);
 
clk_disable(pcdev-clk);
-
-   dev_dbg(icd-parent,
-   OMAP1 Camera driver detached from camera %d\n, icd-devnum);
 }
 
 /* Duplicate standard formats based on host capability of byte swapping */
@@ -1525,6 +1532,8 @@ static struct soc_camera_host_ops omap1_host_ops = {
.owner  = THIS_MODULE,
.add= omap1_cam_add_device,
.remove = omap1_cam_remove_device,
+   .clock_start= omap1_cam_clock_start,
+   .clock_stop = omap1_cam_clock_stop,
.get_formats= omap1_cam_get_formats,
.set_crop   = omap1_cam_set_crop,
.set_fmt= omap1_cam_set_fmt,
-- 
1.7.2.5

--
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 v9 19/20] imx074: support asynchronous probing

2013-04-12 Thread Guennadi Liakhovetski
Both synchronous and asynchronous imx074 subdevice probing is supported by
this patch.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/i2c/soc_camera/imx074.c |   22 +++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/imx074.c 
b/drivers/media/i2c/soc_camera/imx074.c
index a6a5060..c0eed84 100644
--- a/drivers/media/i2c/soc_camera/imx074.c
+++ b/drivers/media/i2c/soc_camera/imx074.c
@@ -18,6 +18,7 @@
 #include linux/module.h
 
 #include media/soc_camera.h
+#include media/v4l2-async.h
 #include media/v4l2-clk.h
 #include media/v4l2-subdev.h
 #include media/v4l2-chip-ident.h
@@ -455,14 +456,27 @@ static int imx074_probe(struct i2c_client *client,
 
priv-fmt   = imx074_colour_fmts[0];
 
+   priv-subdev.dev = client-dev;
+
priv-clk = v4l2_clk_get(client-dev, mclk);
-   if (IS_ERR(priv-clk))
-   return PTR_ERR(priv-clk);
+   if (IS_ERR(priv-clk)) {
+   dev_info(client-dev, Error %ld getting clock\n, 
PTR_ERR(priv-clk));
+   return -EPROBE_DEFER;
+   }
+
+   ret = soc_camera_power_init(client-dev, ssdd);
+   if (ret  0)
+   goto epwrinit;
 
ret = imx074_video_probe(client);
if (ret  0)
-   v4l2_clk_put(priv-clk);
+   goto eprobe;
 
+   return v4l2_async_register_subdev(priv-subdev);
+
+epwrinit:
+eprobe:
+   v4l2_clk_put(priv-clk);
return ret;
 }
 
@@ -471,7 +485,9 @@ static int imx074_remove(struct i2c_client *client)
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
struct imx074 *priv = to_imx074(client);
 
+   v4l2_async_unregister_subdev(priv-subdev);
v4l2_clk_put(priv-clk);
+
if (ssdd-free_bus)
ssdd-free_bus(ssdd);
 
-- 
1.7.2.5

--
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 v9 07/20] atmel-isi: move interface activation and deactivation to clock callbacks

2013-04-12 Thread Guennadi Liakhovetski
When adding and removing a client, the atmel-isi camera host driver only
activates and deactivates its camera interface respectively, which doesn't
include any client-specific actions. Move this functionality into
.clock_start() and .clock_stop() callbacks.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/atmel-isi.c |   28 +
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/soc_camera/atmel-isi.c 
b/drivers/media/platform/soc_camera/atmel-isi.c
index c9e080a..1044856 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -745,10 +745,23 @@ static int isi_camera_get_formats(struct 
soc_camera_device *icd,
return formats;
 }
 
-/* Called with .host_lock held */
 static int isi_camera_add_device(struct soc_camera_device *icd)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
+   dev_dbg(icd-parent, Atmel ISI Camera driver attached to camera %d\n,
+icd-devnum);
+
+   return 0;
+}
+
+static void isi_camera_remove_device(struct soc_camera_device *icd)
+{
+   dev_dbg(icd-parent, Atmel ISI Camera driver detached from camera 
%d\n,
+icd-devnum);
+}
+
+/* Called with .host_lock held */
+static int isi_camera_clock_start(struct soc_camera_host *ici)
+{
struct atmel_isi *isi = ici-priv;
int ret;
 
@@ -762,21 +775,16 @@ static int isi_camera_add_device(struct soc_camera_device 
*icd)
return ret;
}
 
-   dev_dbg(icd-parent, Atmel ISI Camera driver attached to camera %d\n,
-icd-devnum);
return 0;
 }
+
 /* Called with .host_lock held */
-static void isi_camera_remove_device(struct soc_camera_device *icd)
+static void isi_camera_clock_stop(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct atmel_isi *isi = ici-priv;
 
clk_disable(isi-mck);
clk_disable(isi-pclk);
-
-   dev_dbg(icd-parent, Atmel ISI Camera driver detached from camera 
%d\n,
-icd-devnum);
 }
 
 static unsigned int isi_camera_poll(struct file *file, poll_table *pt)
@@ -880,6 +888,8 @@ static struct soc_camera_host_ops isi_soc_camera_host_ops = 
{
.owner  = THIS_MODULE,
.add= isi_camera_add_device,
.remove = isi_camera_remove_device,
+   .clock_start= isi_camera_clock_start,
+   .clock_stop = isi_camera_clock_stop,
.set_fmt= isi_camera_set_fmt,
.try_fmt= isi_camera_try_fmt,
.get_formats= isi_camera_get_formats,
-- 
1.7.2.5

--
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 v9 00/20] V4L2 clock and async patches and soc-camera example

2013-04-12 Thread Guennadi Liakhovetski
Here comes a v9. The most visible change to v8 is the number of patches:-)
The reason is, that I lied in v7. The small change to patch #1 Removed
the struct v4l2-clock subdevice member actually required a lot of changes
to soc-camera to split turning on and off the master clock by camera-host
drivers and attaching a subdevice.

Otherwise the only meaningful changes are to patch #2, they are listed
therein. Otherwise patches #17-20 (former #4-7) have been adjusted to
those changes.

Patches #14,15 are also included this time to keep them in the round. They
have been published earlier too, nothing extraordinary there.

These patches are also available from

git://linuxtv.org/gliakhovetski/v4l-dvb.git v4l2-async

Cc: Guennadi Liakhovetski g.liakhovet...@gmx.de

Guennadi Liakhovetski (20):
  V4L2: add temporary clock helpers
  V4L2: support asynchronous subdevice registration
  soc-camera: move common code to soc_camera.c
  soc-camera: add host clock callbacks to start and stop the master
clock
  pxa-camera: move interface activation and deactivation to clock
callbacks
  omap1-camera: move interface activation and deactivation to clock
callbacks
  atmel-isi: move interface activation and deactivation to clock
callbacks
  mx3-camera: move interface activation and deactivation to clock
callbacks
  mx2-camera: move interface activation and deactivation to clock
callbacks
  mx1-camera: move interface activation and deactivation to clock
callbacks
  sh-mobile-ceu-camera: move interface activation and deactivation to
clock callbacks
  soc-camera: make .clock_{start,stop} compulsory, .add / .remove
optional
  soc-camera: don't attach the client to the host during probing
  sh-mobile-ceu-camera: add primitive OF support
  sh-mobile-ceu-driver: support max width and height in DT
  soc-camera: switch I2C subdevice drivers to use v4l2-clk
  soc-camera: add V4L2-async support
  sh_mobile_ceu_camera: add asynchronous subdevice probing support
  imx074: support asynchronous probing
  ARM: shmobile: convert ap4evb to asynchronously register camera
subdevices

 .../devicetree/bindings/media/sh_mobile_ceu.txt|   18 +
 arch/arm/mach-shmobile/board-ap4evb.c  |  103 ++--
 arch/arm/mach-shmobile/clock-sh7372.c  |1 +
 drivers/media/i2c/soc_camera/imx074.c  |   34 +-
 drivers/media/i2c/soc_camera/mt9m001.c |   17 +-
 drivers/media/i2c/soc_camera/mt9m111.c |   20 +-
 drivers/media/i2c/soc_camera/mt9t031.c |   19 +-
 drivers/media/i2c/soc_camera/mt9t112.c |   19 +-
 drivers/media/i2c/soc_camera/mt9v022.c |   17 +-
 drivers/media/i2c/soc_camera/ov2640.c  |   19 +-
 drivers/media/i2c/soc_camera/ov5642.c  |   20 +-
 drivers/media/i2c/soc_camera/ov6650.c  |   17 +-
 drivers/media/i2c/soc_camera/ov772x.c  |   15 +-
 drivers/media/i2c/soc_camera/ov9640.c  |   17 +-
 drivers/media/i2c/soc_camera/ov9640.h  |1 +
 drivers/media/i2c/soc_camera/ov9740.c  |   18 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |   17 +-
 drivers/media/i2c/soc_camera/tw9910.c  |   18 +-
 drivers/media/platform/soc_camera/atmel-isi.c  |   38 +-
 drivers/media/platform/soc_camera/mx1_camera.c |   48 +-
 drivers/media/platform/soc_camera/mx2_camera.c |   41 +-
 drivers/media/platform/soc_camera/mx3_camera.c |   44 +-
 drivers/media/platform/soc_camera/omap1_camera.c   |   41 +-
 drivers/media/platform/soc_camera/pxa_camera.c |   46 +-
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  243 +--
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  160 +++--
 drivers/media/platform/soc_camera/soc_camera.c |  706 +---
 .../platform/soc_camera/soc_camera_platform.c  |2 +-
 drivers/media/v4l2-core/Makefile   |3 +-
 drivers/media/v4l2-core/v4l2-async.c   |  284 
 drivers/media/v4l2-core/v4l2-clk.c |  177 +
 include/media/sh_mobile_ceu.h  |2 +
 include/media/sh_mobile_csi2.h |2 +-
 include/media/soc_camera.h |   39 +-
 include/media/v4l2-async.h |   99 +++
 include/media/v4l2-clk.h   |   54 ++
 include/media/v4l2-subdev.h|   10 +
 37 files changed, 1956 insertions(+), 473 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/sh_mobile_ceu.txt
 create mode 100644 drivers/media/v4l2-core/v4l2-async.c
 create mode 100644 drivers/media/v4l2-core/v4l2-clk.c
 create mode 100644 include/media/v4l2-async.h
 create mode 100644 include/media/v4l2-clk.h

-- 
1.7.2.5

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the 

[PATCH v9 01/20] V4L2: add temporary clock helpers

2013-04-12 Thread Guennadi Liakhovetski
Typical video devices like camera sensors require an external clock source.
Many such devices cannot even access their hardware registers without a
running clock. These clock sources should be controlled by their consumers.
This should be performed, using the generic clock framework. Unfortunately
so far only very few systems have been ported to that framework. This patch
adds a set of temporary helpers, mimicking the generic clock API, to V4L2.
Platforms, adopting the clock API, should switch to using it. Eventually
this temporary API should be removed.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---

v9: no change

 drivers/media/v4l2-core/Makefile   |2 +-
 drivers/media/v4l2-core/v4l2-clk.c |  177 
 include/media/v4l2-clk.h   |   54 +++
 3 files changed, 232 insertions(+), 1 deletions(-)
 create mode 100644 drivers/media/v4l2-core/v4l2-clk.c
 create mode 100644 include/media/v4l2-clk.h

diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index aa50c46..628c630 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -5,7 +5,7 @@
 tuner-objs :=  tuner-core.o
 
 videodev-objs  :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
-   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o
+   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o
 ifeq ($(CONFIG_COMPAT),y)
   videodev-objs += v4l2-compat-ioctl32.o
 endif
diff --git a/drivers/media/v4l2-core/v4l2-clk.c 
b/drivers/media/v4l2-core/v4l2-clk.c
new file mode 100644
index 000..d7cc13e
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-clk.c
@@ -0,0 +1,177 @@
+/*
+ * V4L2 clock service
+ *
+ * Copyright (C) 2012-2013, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/atomic.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/list.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/slab.h
+#include linux/string.h
+
+#include media/v4l2-clk.h
+#include media/v4l2-subdev.h
+
+static DEFINE_MUTEX(clk_lock);
+static LIST_HEAD(clk_list);
+
+static struct v4l2_clk *v4l2_clk_find(const char *dev_id, const char *id)
+{
+   struct v4l2_clk *clk;
+
+   list_for_each_entry(clk, clk_list, list) {
+   if (strcmp(dev_id, clk-dev_id))
+   continue;
+
+   if (!id || !clk-id || !strcmp(clk-id, id))
+   return clk;
+   }
+
+   return ERR_PTR(-ENODEV);
+}
+
+struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id)
+{
+   struct v4l2_clk *clk;
+
+   mutex_lock(clk_lock);
+   clk = v4l2_clk_find(dev_name(dev), id);
+
+   if (!IS_ERR(clk)  !try_module_get(clk-ops-owner))
+   clk = ERR_PTR(-ENODEV);
+   mutex_unlock(clk_lock);
+
+   if (!IS_ERR(clk))
+   atomic_inc(clk-use_count);
+
+   return clk;
+}
+EXPORT_SYMBOL(v4l2_clk_get);
+
+void v4l2_clk_put(struct v4l2_clk *clk)
+{
+   if (!IS_ERR(clk)) {
+   atomic_dec(clk-use_count);
+   module_put(clk-ops-owner);
+   }
+}
+EXPORT_SYMBOL(v4l2_clk_put);
+
+int v4l2_clk_enable(struct v4l2_clk *clk)
+{
+   int ret;
+   mutex_lock(clk-lock);
+   if (++clk-enable == 1  clk-ops-enable) {
+   ret = clk-ops-enable(clk);
+   if (ret  0)
+   clk-enable--;
+   } else {
+   ret = 0;
+   }
+   mutex_unlock(clk-lock);
+   return ret;
+}
+EXPORT_SYMBOL(v4l2_clk_enable);
+
+void v4l2_clk_disable(struct v4l2_clk *clk)
+{
+   int enable;
+
+   mutex_lock(clk-lock);
+   enable = --clk-enable;
+   if (WARN(enable  0, Unbalanced %s() on %s:%s!\n, __func__,
+clk-dev_id, clk-id))
+   clk-enable++;
+   else if (!enable  clk-ops-disable)
+   clk-ops-disable(clk);
+   mutex_unlock(clk-lock);
+}
+EXPORT_SYMBOL(v4l2_clk_disable);
+
+unsigned long v4l2_clk_get_rate(struct v4l2_clk *clk)
+{
+   if (!clk-ops-get_rate)
+   return -ENOSYS;
+
+   return clk-ops-get_rate(clk);
+}
+EXPORT_SYMBOL(v4l2_clk_get_rate);
+
+int v4l2_clk_set_rate(struct v4l2_clk *clk, unsigned long rate)
+{
+   if (!clk-ops-set_rate)
+   return -ENOSYS;
+
+   return clk-ops-set_rate(clk, rate);
+}
+EXPORT_SYMBOL(v4l2_clk_set_rate);
+
+struct v4l2_clk *v4l2_clk_register(const struct v4l2_clk_ops *ops,
+  const char *dev_id,
+  const char *id, void *priv)
+{
+   struct v4l2_clk *clk;
+   int ret;
+
+   if (!ops || !dev_id)
+   return ERR_PTR(-EINVAL);
+
+   clk = kzalloc(sizeof(struct v4l2_clk), GFP_KERNEL);
+   if (!clk)
+  

[PATCH v9 12/20] soc-camera: make .clock_{start,stop} compulsory, .add / .remove optional

2013-04-12 Thread Guennadi Liakhovetski
All existing soc-camera host drivers use .clock_start() and .clock_stop()
callbacks to activate and deactivate their camera interfaces, whereas
.add() and .remove() callbacks are usually dummy. Make the former two
compulsory and the latter two optional.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/soc_camera.c |   27 +++
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 2f81af5..507f539 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -513,23 +513,22 @@ static int soc_camera_add_device(struct soc_camera_device 
*icd)
if (ici-icd)
return -EBUSY;
 
-   if (ici-ops-clock_start) {
-   ret = ici-ops-clock_start(ici);
+   ret = ici-ops-clock_start(ici);
+   if (ret  0)
+   return ret;
+
+   if (ici-ops-add) {
+   ret = ici-ops-add(icd);
if (ret  0)
-   return ret;
+   goto eadd;
}
 
-   ret = ici-ops-add(icd);
-   if (ret  0)
-   goto eadd;
-
ici-icd = icd;
 
return 0;
 
 eadd:
-   if (ici-ops-clock_stop)
-   ici-ops-clock_stop(ici);
+   ici-ops-clock_stop(ici);
return ret;
 }
 
@@ -540,9 +539,9 @@ static void soc_camera_remove_device(struct 
soc_camera_device *icd)
if (WARN_ON(icd != ici-icd))
return;
 
-   ici-ops-remove(icd);
-   if (ici-ops-clock_stop)
-   ici-ops-clock_stop(ici);
+   if (ici-ops-remove)
+   ici-ops-remove(icd);
+   ici-ops-clock_stop(ici);
ici-icd = NULL;
 }
 
@@ -1413,8 +1412,8 @@ int soc_camera_host_register(struct soc_camera_host *ici)
((!ici-ops-init_videobuf ||
  !ici-ops-reqbufs) 
 !ici-ops-init_videobuf2) ||
-   !ici-ops-add ||
-   !ici-ops-remove ||
+   !ici-ops-clock_start ||
+   !ici-ops-clock_stop ||
!ici-ops-poll ||
!ici-v4l2_dev.dev)
return -EINVAL;
-- 
1.7.2.5

--
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 v9 17/20] soc-camera: add V4L2-async support

2013-04-12 Thread Guennadi Liakhovetski
Add support for asynchronous subdevice probing, using the v4l2-async API.
The legacy synchronous mode is still supported too, which allows to
gradually update drivers and platforms. The selected approach adds a
notifier for each struct soc_camera_device instance, i.e. for each video
device node, even when there are multiple such instances registered with a
single soc-camera host simultaneously.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/soc_camera.c |  526 
 include/media/soc_camera.h |   23 +-
 2 files changed, 463 insertions(+), 86 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index cfcdabe..a790f81 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -21,22 +21,23 @@
 #include linux/i2c.h
 #include linux/init.h
 #include linux/list.h
-#include linux/mutex.h
 #include linux/module.h
+#include linux/mutex.h
 #include linux/platform_device.h
+#include linux/pm_runtime.h
 #include linux/regulator/consumer.h
 #include linux/slab.h
-#include linux/pm_runtime.h
 #include linux/vmalloc.h
 
 #include media/soc_camera.h
+#include media/soc_mediabus.h
+#include media/v4l2-async.h
 #include media/v4l2-clk.h
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-dev.h
 #include media/videobuf-core.h
 #include media/videobuf2-core.h
-#include media/soc_mediabus.h
 
 /* Default to VGA resolution */
 #define DEFAULT_WIDTH  640
@@ -47,23 +48,39 @@
 (icd)-vb_vidq.streaming : \
 vb2_is_streaming((icd)-vb2_vidq))
 
+#define MAP_MAX_NUM 32
+static DECLARE_BITMAP(device_map, MAP_MAX_NUM);
 static LIST_HEAD(hosts);
 static LIST_HEAD(devices);
-static DEFINE_MUTEX(list_lock);/* Protects the list of hosts */
+/*
+ * Protects lists and bitmaps of hosts and devices.
+ * Lock nesting: Ok to take -host_lock under list_lock.
+ */
+static DEFINE_MUTEX(list_lock);
+
+struct soc_camera_async_client {
+   struct v4l2_async_subdev *sensor;
+   struct v4l2_async_notifier notifier;
+   struct platform_device *pdev;
+   struct list_head list;  /* needed for clean up */
+};
+
+static int soc_camera_video_start(struct soc_camera_device *icd);
+static int video_dev_create(struct soc_camera_device *icd);
 
 int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc 
*ssdd,
struct v4l2_clk *clk)
 {
int ret = clk ? v4l2_clk_enable(clk) : 0;
if (ret  0) {
-   dev_err(dev, Cannot enable clock\n);
+   dev_err(dev, Cannot enable clock: %d\n, ret);
return ret;
}
ret = regulator_bulk_enable(ssdd-num_regulators,
ssdd-regulators);
if (ret  0) {
dev_err(dev, Cannot enable regulators\n);
-   goto eregenable;;
+   goto eregenable;
}
 
if (ssdd-power) {
@@ -117,6 +134,14 @@ int soc_camera_power_off(struct device *dev, struct 
soc_camera_subdev_desc *ssdd
 }
 EXPORT_SYMBOL(soc_camera_power_off);
 
+int soc_camera_power_init(struct device *dev, struct soc_camera_subdev_desc 
*ssdd)
+{
+
+   return devm_regulator_bulk_get(dev, ssdd-num_regulators,
+  ssdd-regulators);
+}
+EXPORT_SYMBOL(soc_camera_power_init);
+
 static int __soc_camera_power_on(struct soc_camera_device *icd)
 {
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
@@ -533,7 +558,9 @@ static int soc_camera_add_device(struct soc_camera_device 
*icd)
return -EBUSY;
 
if (!icd-clk) {
+   mutex_lock(ici-clk_lock);
ret = ici-ops-clock_start(ici);
+   mutex_unlock(ici-clk_lock);
if (ret  0)
return ret;
}
@@ -549,8 +576,11 @@ static int soc_camera_add_device(struct soc_camera_device 
*icd)
return 0;
 
 eadd:
-   if (!icd-clk)
+   if (!icd-clk) {
+   mutex_lock(ici-clk_lock);
ici-ops-clock_stop(ici);
+   mutex_unlock(ici-clk_lock);
+   }
return ret;
 }
 
@@ -563,8 +593,11 @@ static void soc_camera_remove_device(struct 
soc_camera_device *icd)
 
if (ici-ops-remove)
ici-ops-remove(icd);
-   if (!icd-clk)
+   if (!icd-clk) {
+   mutex_lock(ici-clk_lock);
ici-ops-clock_stop(ici);
+   mutex_unlock(ici-clk_lock);
+   }
ici-icd = NULL;
 }
 
@@ -673,8 +706,8 @@ static int soc_camera_open(struct file *file)
return 0;
 
/*
-* First four errors are entered with the .host_lock held
-* and use_count == 1
+* All errors are entered with the .host_lock held, first four also
+* with use_count == 1
 */
 einitvb:
 

[PATCH v9 16/20] soc-camera: switch I2C subdevice drivers to use v4l2-clk

2013-04-12 Thread Guennadi Liakhovetski
Instead of centrally enabling and disabling subdevice master clocks in
soc-camera core, let subdevice drivers do that themselves, using the
V4L2 clock API and soc-camera convenience wrappers.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/i2c/soc_camera/imx074.c  |   18 ++-
 drivers/media/i2c/soc_camera/mt9m001.c |   17 ++-
 drivers/media/i2c/soc_camera/mt9m111.c |   20 ++-
 drivers/media/i2c/soc_camera/mt9t031.c |   19 ++-
 drivers/media/i2c/soc_camera/mt9t112.c |   19 ++-
 drivers/media/i2c/soc_camera/mt9v022.c |   17 ++-
 drivers/media/i2c/soc_camera/ov2640.c  |   19 ++-
 drivers/media/i2c/soc_camera/ov5642.c  |   20 ++-
 drivers/media/i2c/soc_camera/ov6650.c  |   17 ++-
 drivers/media/i2c/soc_camera/ov772x.c  |   15 ++-
 drivers/media/i2c/soc_camera/ov9640.c  |   17 ++-
 drivers/media/i2c/soc_camera/ov9640.h  |1 +
 drivers/media/i2c/soc_camera/ov9740.c  |   18 ++-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |   17 ++-
 drivers/media/i2c/soc_camera/tw9910.c  |   18 ++-
 drivers/media/platform/soc_camera/soc_camera.c |  162 +++-
 .../platform/soc_camera/soc_camera_platform.c  |2 +-
 include/media/soc_camera.h |   13 +-
 18 files changed, 350 insertions(+), 79 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/imx074.c 
b/drivers/media/i2c/soc_camera/imx074.c
index a2a5cbb..a6a5060 100644
--- a/drivers/media/i2c/soc_camera/imx074.c
+++ b/drivers/media/i2c/soc_camera/imx074.c
@@ -18,6 +18,7 @@
 #include linux/module.h
 
 #include media/soc_camera.h
+#include media/v4l2-clk.h
 #include media/v4l2-subdev.h
 #include media/v4l2-chip-ident.h
 
@@ -77,6 +78,7 @@ struct imx074_datafmt {
 struct imx074 {
struct v4l2_subdev  subdev;
const struct imx074_datafmt *fmt;
+   struct v4l2_clk *clk;
 };
 
 static const struct imx074_datafmt imx074_colour_fmts[] = {
@@ -272,8 +274,9 @@ static int imx074_s_power(struct v4l2_subdev *sd, int on)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
+   struct imx074 *priv = to_imx074(client);
 
-   return soc_camera_set_power(client-dev, ssdd, on);
+   return soc_camera_set_power(client-dev, ssdd, priv-clk, on);
 }
 
 static int imx074_g_mbus_config(struct v4l2_subdev *sd,
@@ -431,6 +434,7 @@ static int imx074_probe(struct i2c_client *client,
struct imx074 *priv;
struct i2c_adapter *adapter = to_i2c_adapter(client-dev.parent);
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
+   int ret;
 
if (!ssdd) {
dev_err(client-dev, IMX074: missing platform data!\n);
@@ -451,13 +455,23 @@ static int imx074_probe(struct i2c_client *client,
 
priv-fmt   = imx074_colour_fmts[0];
 
-   return imx074_video_probe(client);
+   priv-clk = v4l2_clk_get(client-dev, mclk);
+   if (IS_ERR(priv-clk))
+   return PTR_ERR(priv-clk);
+
+   ret = imx074_video_probe(client);
+   if (ret  0)
+   v4l2_clk_put(priv-clk);
+
+   return ret;
 }
 
 static int imx074_remove(struct i2c_client *client)
 {
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
+   struct imx074 *priv = to_imx074(client);
 
+   v4l2_clk_put(priv-clk);
if (ssdd-free_bus)
ssdd-free_bus(ssdd);
 
diff --git a/drivers/media/i2c/soc_camera/mt9m001.c 
b/drivers/media/i2c/soc_camera/mt9m001.c
index dd90898..620f9df 100644
--- a/drivers/media/i2c/soc_camera/mt9m001.c
+++ b/drivers/media/i2c/soc_camera/mt9m001.c
@@ -16,6 +16,7 @@
 
 #include media/soc_camera.h
 #include media/soc_mediabus.h
+#include media/v4l2-clk.h
 #include media/v4l2-subdev.h
 #include media/v4l2-chip-ident.h
 #include media/v4l2-ctrls.h
@@ -94,6 +95,7 @@ struct mt9m001 {
struct v4l2_ctrl *exposure;
};
struct v4l2_rect rect;  /* Sensor window */
+   struct v4l2_clk *clk;
const struct mt9m001_datafmt *fmt;
const struct mt9m001_datafmt *fmts;
int num_fmts;
@@ -381,8 +383,9 @@ static int mt9m001_s_power(struct v4l2_subdev *sd, int on)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
+   struct mt9m001 *mt9m001 = to_mt9m001(client);
 
-   return soc_camera_set_power(client-dev, ssdd, on);
+   return soc_camera_set_power(client-dev, ssdd, mt9m001-clk, on);
 }
 
 static int mt9m001_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
@@ -710,9 +713,18 @@ static int mt9m001_probe(struct i2c_client *client,
mt9m001-rect.width = MT9M001_MAX_WIDTH;
mt9m001-rect.height= MT9M001_MAX_HEIGHT;
 
+   mt9m001-clk = 

[PATCH v9 14/20] sh-mobile-ceu-camera: add primitive OF support

2013-04-12 Thread Guennadi Liakhovetski
Add an OF hook to sh_mobile_ceu_camera.c, no properties so far. Booting
with DT also requires platform data to be optional.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 .../platform/soc_camera/sh_mobile_ceu_camera.c |   33 ++--
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c 
b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 9037472..fcc13d8 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -27,6 +27,7 @@
 #include linux/kernel.h
 #include linux/mm.h
 #include linux/moduleparam.h
+#include linux/of.h
 #include linux/time.h
 #include linux/slab.h
 #include linux/device.h
@@ -118,6 +119,7 @@ struct sh_mobile_ceu_dev {
 
enum v4l2_field field;
int sequence;
+   unsigned long flags;
 
unsigned int image_mode:1;
unsigned int is_16bit:1;
@@ -706,7 +708,7 @@ static void sh_mobile_ceu_set_rect(struct soc_camera_device 
*icd)
}
 
/* CSI2 special configuration */
-   if (pcdev-pdata-csi2) {
+   if (pcdev-csi2_pdev) {
in_width = ((in_width - 2) * 2);
left_offset *= 2;
}
@@ -810,7 +812,7 @@ static int sh_mobile_ceu_set_bus_param(struct 
soc_camera_device *icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (pcdev-pdata-flags  SH_CEU_FLAG_HSYNC_LOW)
+   if (pcdev-flags  SH_CEU_FLAG_HSYNC_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -818,7 +820,7 @@ static int sh_mobile_ceu_set_bus_param(struct 
soc_camera_device *icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (pcdev-pdata-flags  SH_CEU_FLAG_VSYNC_LOW)
+   if (pcdev-flags  SH_CEU_FLAG_VSYNC_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -873,11 +875,11 @@ static int sh_mobile_ceu_set_bus_param(struct 
soc_camera_device *icd)
value |= common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW ? 1  1 : 0;
value |= common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW ? 1  0 : 0;
 
-   if (pcdev-pdata-csi2) /* CSI2 mode */
+   if (pcdev-csi2_pdev) /* CSI2 mode */
value |= 3  12;
else if (pcdev-is_16bit)
value |= 1  12;
-   else if (pcdev-pdata-flags  SH_CEU_FLAG_LOWER_8BIT)
+   else if (pcdev-flags  SH_CEU_FLAG_LOWER_8BIT)
value |= 2  12;
 
ceu_write(pcdev, CAMCR, value);
@@ -1052,7 +1054,7 @@ static int sh_mobile_ceu_get_formats(struct 
soc_camera_device *icd, unsigned int
return 0;
}
 
-   if (!pcdev-pdata-csi2) {
+   if (!pcdev-pdata || !pcdev-pdata-csi2) {
/* Are there any restrictions in the CSI-2 case? */
ret = sh_mobile_ceu_try_bus_param(icd, fmt-bits_per_sample);
if (ret  0)
@@ -2107,13 +2109,17 @@ static int sh_mobile_ceu_probe(struct platform_device 
*pdev)
init_completion(pcdev-complete);
 
pcdev-pdata = pdev-dev.platform_data;
-   if (!pcdev-pdata) {
+   if (!pcdev-pdata  !pdev-dev.of_node) {
dev_err(pdev-dev, CEU platform data not set.\n);
return -EINVAL;
}
 
-   pcdev-max_width = pcdev-pdata-max_width ? : 2560;
-   pcdev-max_height = pcdev-pdata-max_height ? : 1920;
+   /* TODO: implement per-device bus flags */
+   if (pcdev-pdata) {
+   pcdev-max_width = pcdev-pdata-max_width ? : 2560;
+   pcdev-max_height = pcdev-pdata-max_height ? : 1920;
+   pcdev-flags = pcdev-pdata-flags;
+   }
 
base = devm_ioremap_resource(pdev-dev, res);
if (IS_ERR(base))
@@ -2168,7 +2174,7 @@ static int sh_mobile_ceu_probe(struct platform_device 
*pdev)
goto exit_free_ctx;
 
/* CSI2 interfacing */
-   csi2 = pcdev-pdata-csi2;
+   csi2 = pcdev-pdata ? pcdev-pdata-csi2 : NULL;
if (csi2) {
struct platform_device *csi2_pdev =
platform_device_alloc(sh-mobile-csi2, csi2-id);
@@ -2290,10 +2296,17 @@ static const struct dev_pm_ops sh_mobile_ceu_dev_pm_ops 
= {
.runtime_resume = sh_mobile_ceu_runtime_nop,
 };
 
+static const struct of_device_id sh_mobile_ceu_of_match[] = {
+   { .compatible = renesas,sh-mobile-ceu },
+   { }
+};
+MODULE_DEVICE_TABLE(of, sh_mobile_ceu_of_match);
+
 static struct platform_driver sh_mobile_ceu_driver = {
.driver = {
.name   = sh_mobile_ceu,
   

[PATCH v9 13/20] soc-camera: don't attach the client to the host during probing

2013-04-12 Thread Guennadi Liakhovetski
During client probing we only have to turn on the host's clock, no need to
actually attach the client to the host.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/soc_camera.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 507f539..f693817 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1207,7 +1207,7 @@ static int soc_camera_probe(struct soc_camera_device *icd)
ssdd-reset(icd-pdev);
 
mutex_lock(ici-host_lock);
-   ret = soc_camera_add_device(icd);
+   ret = ici-ops-clock_start(ici);
mutex_unlock(ici-host_lock);
if (ret  0)
goto eadd;
@@ -1280,7 +1280,7 @@ static int soc_camera_probe(struct soc_camera_device *icd)
icd-field  = mf.field;
}
 
-   soc_camera_remove_device(icd);
+   ici-ops-clock_stop(ici);
 
mutex_unlock(ici-host_lock);
 
@@ -1303,7 +1303,7 @@ eadddev:
icd-vdev = NULL;
 evdc:
mutex_lock(ici-host_lock);
-   soc_camera_remove_device(icd);
+   ici-ops-clock_stop(ici);
mutex_unlock(ici-host_lock);
 eadd:
v4l2_ctrl_handler_free(icd-ctrl_handler);
-- 
1.7.2.5

--
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 v9 18/20] sh_mobile_ceu_camera: add asynchronous subdevice probing support

2013-04-12 Thread Guennadi Liakhovetski
Use the v4l2-async API to support asynchronous subdevice probing,
including the CSI2 subdevice. Synchronous probing is still supported too.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  134 -
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  160 +++-
 include/media/sh_mobile_ceu.h  |2 +
 include/media/sh_mobile_csi2.h |2 +-
 4 files changed, 191 insertions(+), 107 deletions(-)

diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c 
b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index b0f0995..99d9029 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -36,6 +36,7 @@
 #include linux/pm_runtime.h
 #include linux/sched.h
 
+#include media/v4l2-async.h
 #include media/v4l2-common.h
 #include media/v4l2-dev.h
 #include media/soc_camera.h
@@ -96,6 +97,10 @@ struct sh_mobile_ceu_buffer {
 
 struct sh_mobile_ceu_dev {
struct soc_camera_host ici;
+   /* Asynchronous CSI2 linking */
+   struct v4l2_async_subdev *csi2_asd;
+   struct v4l2_subdev *csi2_sd;
+   /* Synchronous probing compatibility */
struct platform_device *csi2_pdev;
 
unsigned int irq;
@@ -185,7 +190,6 @@ static int sh_mobile_ceu_soft_reset(struct 
sh_mobile_ceu_dev *pcdev)
udelay(1);
}
 
-
if (2 != success) {
dev_warn(pcdev-ici.v4l2_dev.dev, soft reset time out\n);
return -EIO;
@@ -534,16 +538,29 @@ static struct v4l2_subdev *find_csi2(struct 
sh_mobile_ceu_dev *pcdev)
 {
struct v4l2_subdev *sd;
 
-   if (!pcdev-csi2_pdev)
-   return NULL;
+   if (pcdev-csi2_sd)
+   return pcdev-csi2_sd;
 
-   v4l2_device_for_each_subdev(sd, pcdev-ici.v4l2_dev)
-   if (pcdev-csi2_pdev-dev == v4l2_get_subdevdata(sd))
-   return sd;
+   if (pcdev-csi2_asd) {
+   char name[] = sh-mobile-csi2;
+   v4l2_device_for_each_subdev(sd, pcdev-ici.v4l2_dev)
+   if (!strncmp(name, sd-name, sizeof(name) - 1)) {
+   pcdev-csi2_sd = sd;
+   return sd;
+   }
+   }
 
return NULL;
 }
 
+static struct v4l2_subdev *csi2_subdev(struct sh_mobile_ceu_dev *pcdev,
+  struct soc_camera_device *icd)
+{
+   struct v4l2_subdev *sd = pcdev-csi2_sd;
+
+   return sd  sd-grp_id == soc_camera_grp_id(icd) ? sd : NULL;
+}
+
 static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)
 {
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
@@ -564,12 +581,12 @@ static int sh_mobile_ceu_add_device(struct 
soc_camera_device *icd)
 * -ENODEV is special: either csi2_sd == NULL or the CSI-2 driver
 * has not found this soc-camera device among its clients
 */
-   if (ret == -ENODEV  csi2_sd)
+   if (csi2_sd  ret == -ENODEV)
csi2_sd-grp_id = 0;
 
dev_info(icd-parent,
-SuperH Mobile CEU driver attached to camera %d\n,
-icd-devnum);
+SuperH Mobile CEU%s driver attached to camera %d\n,
+csi2_sd  csi2_sd-grp_id ? /CSI-2 : , icd-devnum);
 
return 0;
 }
@@ -585,8 +602,6 @@ static void sh_mobile_ceu_remove_device(struct 
soc_camera_device *icd)
 icd-devnum);
 
v4l2_subdev_call(csi2_sd, core, s_power, 0);
-   if (csi2_sd)
-   csi2_sd-grp_id = 0;
 }
 
 /* Called with .host_lock held */
@@ -708,7 +723,7 @@ static void sh_mobile_ceu_set_rect(struct soc_camera_device 
*icd)
}
 
/* CSI2 special configuration */
-   if (pcdev-csi2_pdev) {
+   if (csi2_subdev(pcdev, icd)) {
in_width = ((in_width - 2) * 2);
left_offset *= 2;
}
@@ -765,13 +780,7 @@ static void capture_restore(struct sh_mobile_ceu_dev 
*pcdev, u32 capsr)
 static struct v4l2_subdev *find_bus_subdev(struct sh_mobile_ceu_dev *pcdev,
   struct soc_camera_device *icd)
 {
-   if (pcdev-csi2_pdev) {
-   struct v4l2_subdev *csi2_sd = find_csi2(pcdev);
-   if (csi2_sd  csi2_sd-grp_id == soc_camera_grp_id(icd))
-   return csi2_sd;
-   }
-
-   return soc_camera_to_subdev(icd);
+   return csi2_subdev(pcdev, icd) ? : soc_camera_to_subdev(icd);
 }
 
 #define CEU_BUS_FLAGS (V4L2_MBUS_MASTER |  \
@@ -875,7 +884,7 @@ static int sh_mobile_ceu_set_bus_param(struct 
soc_camera_device *icd)
value |= common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW ? 1  1 : 0;
value |= common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW ? 1  0 : 0;
 
-   if (pcdev-csi2_pdev) /* CSI2 mode */
+   if (csi2_subdev(pcdev, icd)) 

[PATCH v9 15/20] sh-mobile-ceu-driver: support max width and height in DT

2013-04-12 Thread Guennadi Liakhovetski
Some CEU implementations have non-standard (larger) maximum supported
width and height values. Add two OF properties to specify them.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 .../devicetree/bindings/media/sh_mobile_ceu.txt|   18 +++
 .../platform/soc_camera/sh_mobile_ceu_camera.c |   23 ++-
 2 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/sh_mobile_ceu.txt

diff --git a/Documentation/devicetree/bindings/media/sh_mobile_ceu.txt 
b/Documentation/devicetree/bindings/media/sh_mobile_ceu.txt
new file mode 100644
index 000..1ce4e46
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/sh_mobile_ceu.txt
@@ -0,0 +1,18 @@
+Bindings, specific for the sh_mobile_ceu_camera.c driver:
+ - compatible: Should be renesas,sh-mobile-ceu
+ - reg: register base and size
+ - interrupts: the interrupt number
+ - interrupt-parent: the interrupt controller
+ - renesas,max-width: maximum image width, supported on this SoC
+ - renesas,max-height: maximum image height, supported on this SoC
+
+Example:
+
+ceu0: ceu@0xfe91 {
+   compatible = renesas,sh-mobile-ceu;
+   reg = 0xfe91 0xa0;
+   interrupt-parent = intcs;
+   interrupts = 0x880;
+   renesas,max-width = 8188;
+   renesas,max-height = 8188;
+};
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c 
b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index fcc13d8..b0f0995 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -2116,11 +2116,30 @@ static int sh_mobile_ceu_probe(struct platform_device 
*pdev)
 
/* TODO: implement per-device bus flags */
if (pcdev-pdata) {
-   pcdev-max_width = pcdev-pdata-max_width ? : 2560;
-   pcdev-max_height = pcdev-pdata-max_height ? : 1920;
+   pcdev-max_width = pcdev-pdata-max_width;
+   pcdev-max_height = pcdev-pdata-max_height;
pcdev-flags = pcdev-pdata-flags;
}
 
+   if (!pcdev-max_width) {
+   unsigned int v;
+   err = of_property_read_u32(pdev-dev.of_node, 
renesas,max-width, v);
+   if (!err)
+   pcdev-max_width = v;
+
+   if (!pcdev-max_width)
+   pcdev-max_width = 2560;
+   }
+   if (!pcdev-max_height) {
+   unsigned int v;
+   err = of_property_read_u32(pdev-dev.of_node, 
renesas,max-height, v);
+   if (!err)
+   pcdev-max_height = v;
+
+   if (!pcdev-max_height)
+   pcdev-max_height = 1920;
+   }
+
base = devm_ioremap_resource(pdev-dev, res);
if (IS_ERR(base))
return PTR_ERR(base);
-- 
1.7.2.5

--
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 v9 09/20] mx2-camera: move interface activation and deactivation to clock callbacks

2013-04-12 Thread Guennadi Liakhovetski
When adding and removing a client, the mx2-camera driver only activates
and deactivates its camera interface respectively, which doesn't include
any client-specific actions. Move this functionality into .clock_start()
and .clock_stop() callbacks.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/mx2_camera.c |   28 +++
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/soc_camera/mx2_camera.c 
b/drivers/media/platform/soc_camera/mx2_camera.c
index 772e071..45a0276 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -412,13 +412,26 @@ static void mx2_camera_deactivate(struct mx2_camera_dev 
*pcdev)
writel(0, pcdev-base_emma + PRP_CNTL);
 }
 
+static int mx2_camera_add_device(struct soc_camera_device *icd)
+{
+   dev_info(icd-parent, Camera driver attached to camera %d\n,
+icd-devnum);
+
+   return 0;
+}
+
+static void mx2_camera_remove_device(struct soc_camera_device *icd)
+{
+   dev_info(icd-parent, Camera driver detached from camera %d\n,
+icd-devnum);
+}
+
 /*
  * The following two functions absolutely depend on the fact, that
  * there can be only one camera on mx2 camera sensor interface
  */
-static int mx2_camera_add_device(struct soc_camera_device *icd)
+static int mx2_camera_clock_start(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct mx2_camera_dev *pcdev = ici-priv;
int ret;
u32 csicr1;
@@ -439,9 +452,6 @@ static int mx2_camera_add_device(struct soc_camera_device 
*icd)
 
pcdev-frame_count = 0;
 
-   dev_info(icd-parent, Camera driver attached to camera %d\n,
-icd-devnum);
-
return 0;
 
 exit_csi_ahb:
@@ -450,14 +460,10 @@ exit_csi_ahb:
return ret;
 }
 
-static void mx2_camera_remove_device(struct soc_camera_device *icd)
+static void mx2_camera_clock_stop(struct soc_camera_host *ici)
 {
-   struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct mx2_camera_dev *pcdev = ici-priv;
 
-   dev_info(icd-parent, Camera driver detached from camera %d\n,
-icd-devnum);
-
mx2_camera_deactivate(pcdev);
 }
 
@@ -1271,6 +1277,8 @@ static struct soc_camera_host_ops mx2_soc_camera_host_ops 
= {
.owner  = THIS_MODULE,
.add= mx2_camera_add_device,
.remove = mx2_camera_remove_device,
+   .clock_start= mx2_camera_clock_start,
+   .clock_stop = mx2_camera_clock_stop,
.set_fmt= mx2_camera_set_fmt,
.set_crop   = mx2_camera_set_crop,
.get_formats= mx2_camera_get_formats,
-- 
1.7.2.5

--
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 v9 03/20] soc-camera: move common code to soc_camera.c

2013-04-12 Thread Guennadi Liakhovetski
All soc-camera host drivers include a pointer to an soc-camera device in
their host private struct to check, that only one client is connected.
Move this common code to soc_camera.c.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/atmel-isi.c  |   10 +-
 drivers/media/platform/soc_camera/mx1_camera.c |   20 +++
 drivers/media/platform/soc_camera/mx2_camera.c |   13 +--
 drivers/media/platform/soc_camera/mx3_camera.c |9 -
 drivers/media/platform/soc_camera/omap1_camera.c   |   14 +--
 drivers/media/platform/soc_camera/pxa_camera.c |   18 ++---
 .../platform/soc_camera/sh_mobile_ceu_camera.c |   13 +--
 drivers/media/platform/soc_camera/soc_camera.c |   38 ---
 include/media/soc_camera.h |1 +
 9 files changed, 49 insertions(+), 87 deletions(-)

diff --git a/drivers/media/platform/soc_camera/atmel-isi.c 
b/drivers/media/platform/soc_camera/atmel-isi.c
index 1abbb36..c9e080a 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -102,7 +102,6 @@ struct atmel_isi {
struct list_headvideo_buffer_list;
struct frame_buffer *active;
 
-   struct soc_camera_device*icd;
struct soc_camera_host  soc_host;
 };
 
@@ -367,7 +366,7 @@ static void start_dma(struct atmel_isi *isi, struct 
frame_buffer *buffer)
 
/* Check if already in a frame */
if (isi_readl(isi, ISI_STATUS)  ISI_CTRL_CDC) {
-   dev_err(isi-icd-parent, Already in frame handling.\n);
+   dev_err(isi-soc_host.icd-parent, Already in frame 
handling.\n);
return;
}
 
@@ -753,9 +752,6 @@ static int isi_camera_add_device(struct soc_camera_device 
*icd)
struct atmel_isi *isi = ici-priv;
int ret;
 
-   if (isi-icd)
-   return -EBUSY;
-
ret = clk_enable(isi-pclk);
if (ret)
return ret;
@@ -766,7 +762,6 @@ static int isi_camera_add_device(struct soc_camera_device 
*icd)
return ret;
}
 
-   isi-icd = icd;
dev_dbg(icd-parent, Atmel ISI Camera driver attached to camera %d\n,
 icd-devnum);
return 0;
@@ -777,11 +772,8 @@ static void isi_camera_remove_device(struct 
soc_camera_device *icd)
struct soc_camera_host *ici = to_soc_camera_host(icd-parent);
struct atmel_isi *isi = ici-priv;
 
-   BUG_ON(icd != isi-icd);
-
clk_disable(isi-mck);
clk_disable(isi-pclk);
-   isi-icd = NULL;
 
dev_dbg(icd-parent, Atmel ISI Camera driver detached from camera 
%d\n,
 icd-devnum);
diff --git a/drivers/media/platform/soc_camera/mx1_camera.c 
b/drivers/media/platform/soc_camera/mx1_camera.c
index a3fd8d6..5f9ec8e 100644
--- a/drivers/media/platform/soc_camera/mx1_camera.c
+++ b/drivers/media/platform/soc_camera/mx1_camera.c
@@ -104,7 +104,6 @@ struct mx1_buffer {
  */
 struct mx1_camera_dev {
struct soc_camera_host  soc_host;
-   struct soc_camera_device*icd;
struct mx1_camera_pdata *pdata;
struct mx1_buffer   *active;
struct resource *res;
@@ -220,7 +219,7 @@ out:
 static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
 {
struct videobuf_buffer *vbuf = pcdev-active-vb;
-   struct device *dev = pcdev-icd-parent;
+   struct device *dev = pcdev-soc_host.icd-parent;
int ret;
 
if (unlikely(!pcdev-active)) {
@@ -331,7 +330,7 @@ static void mx1_camera_wakeup(struct mx1_camera_dev *pcdev,
 static void mx1_camera_dma_irq(int channel, void *data)
 {
struct mx1_camera_dev *pcdev = data;
-   struct device *dev = pcdev-icd-parent;
+   struct device *dev = pcdev-soc_host.icd-parent;
struct mx1_buffer *buf;
struct videobuf_buffer *vb;
unsigned long flags;
@@ -389,7 +388,7 @@ static int mclk_get_divisor(struct mx1_camera_dev *pcdev)
 */
div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1;
 
-   dev_dbg(pcdev-icd-parent,
+   dev_dbg(pcdev-soc_host.icd-parent,
System clock %lukHz, target freq %dkHz, divisor %lu\n,
lcdclk / 1000, mclk / 1000, div);
 
@@ -400,7 +399,7 @@ static void mx1_camera_activate(struct mx1_camera_dev 
*pcdev)
 {
unsigned int csicr1 = CSICR1_EN;
 
-   dev_dbg(pcdev-icd-parent, Activate device\n);
+   dev_dbg(pcdev-soc_host.icd-parent, Activate device\n);
 
clk_prepare_enable(pcdev-clk);
 
@@ -416,7 +415,7 @@ static void mx1_camera_activate(struct mx1_camera_dev 
*pcdev)
 
 static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
 {
-   dev_dbg(pcdev-icd-parent, Deactivate device\n);
+   dev_dbg(pcdev-soc_host.icd-parent, Deactivate device\n);
 
/* Disable all CSI interface */

[PATCH v9 04/20] soc-camera: add host clock callbacks to start and stop the master clock

2013-04-12 Thread Guennadi Liakhovetski
Currently soc-camera uses a single camera host callback to activate the
interface master clock and to configure the interface for a specific
client. However, during probing we might not have the information about
a client, we just need to activate the clock. Add new camera host driver
callbacks to only start and stop the clock without and client-specific
configuration.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 drivers/media/platform/soc_camera/soc_camera.c |   19 +--
 include/media/soc_camera.h |2 ++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index e32e4e2..2f81af5 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -513,10 +513,23 @@ static int soc_camera_add_device(struct soc_camera_device 
*icd)
if (ici-icd)
return -EBUSY;
 
+   if (ici-ops-clock_start) {
+   ret = ici-ops-clock_start(ici);
+   if (ret  0)
+   return ret;
+   }
+
ret = ici-ops-add(icd);
-   if (!ret)
-   ici-icd = icd;
+   if (ret  0)
+   goto eadd;
+
+   ici-icd = icd;
 
+   return 0;
+
+eadd:
+   if (ici-ops-clock_stop)
+   ici-ops-clock_stop(ici);
return ret;
 }
 
@@ -528,6 +541,8 @@ static void soc_camera_remove_device(struct 
soc_camera_device *icd)
return;
 
ici-ops-remove(icd);
+   if (ici-ops-clock_stop)
+   ici-ops-clock_stop(ici);
ici-icd = NULL;
 }
 
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 5a46ce2..64415ee 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -74,6 +74,8 @@ struct soc_camera_host_ops {
struct module *owner;
int (*add)(struct soc_camera_device *);
void (*remove)(struct soc_camera_device *);
+   int (*clock_start)(struct soc_camera_host *);
+   void (*clock_stop)(struct soc_camera_host *);
/*
 * .get_formats() is called for each client device format, but
 * .put_formats() is only called once. Further, if any of the calls to
-- 
1.7.2.5

--
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


[GIT PULL] 3.10: soc-camera take 3

2013-04-12 Thread Guennadi Liakhovetski
Hi Mauro

Just two more patches for 3.10. Note, that one of them is for MAINTAINERS. 
Should it go via media or via someone else's tree?

The following changes since commit 81e096c8ac6a064854c2157e0bf802dc4906678c:

  [media] budget: Add support for Philips Semi Sylt PCI ref. design (2013-04-08 
07:28:01 -0300)

are available in the git repository at:
  git://linuxtv.org/gliakhovetski/v4l-dvb.git for-3.10-3

Guennadi Liakhovetski (1):
  soc-camera: fix typos in the default format-conversion table

Laurent Pinchart (1):
  MAINTAINERS: Mark the SH VOU driver as Odd Fixes

 MAINTAINERS  |2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
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 v9 02/20] V4L2: support asynchronous subdevice registration

2013-04-12 Thread Guennadi Liakhovetski
Currently bridge device drivers register devices for all subdevices
synchronously, tupically, during their probing. E.g. if an I2C CMOS sensor
is attached to a video bridge device, the bridge driver will create an I2C
device and wait for the respective I2C driver to probe. This makes linking
of devices straight forward, but this approach cannot be used with
intrinsically asynchronous and unordered device registration systems like
the Flattened Device Tree. To support such systems this patch adds an
asynchronous subdevice registration framework to V4L2. To use it respective
(e.g. I2C) subdevice drivers must register themselves with the framework.
A bridge driver on the other hand must register notification callbacks,
that will be called upon various related events.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---

v9: addressed Laurent's comments (thanks)
1. moved valid hw-bus_type check
2. made v4l2_async_unregister() void
3. renamed struct v4l2_async_hw_device to struct v4l2_async_hw_info
4. merged struct v4l2_async_subdev_list into struct v4l2_subdev
5. fixed a typo
6. made subdev_num unsigned

 drivers/media/v4l2-core/Makefile |3 +-
 drivers/media/v4l2-core/v4l2-async.c |  284 ++
 include/media/v4l2-async.h   |   99 
 include/media/v4l2-subdev.h  |   10 ++
 4 files changed, 395 insertions(+), 1 deletions(-)
 create mode 100644 drivers/media/v4l2-core/v4l2-async.c
 create mode 100644 include/media/v4l2-async.h

diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index 628c630..4c33b8d6 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -5,7 +5,8 @@
 tuner-objs :=  tuner-core.o
 
 videodev-objs  :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
-   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o
+   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o \
+   v4l2-async.o
 ifeq ($(CONFIG_COMPAT),y)
   videodev-objs += v4l2-compat-ioctl32.o
 endif
diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
new file mode 100644
index 000..98db2e0
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -0,0 +1,284 @@
+/*
+ * V4L2 asynchronous subdevice registration API
+ *
+ * Copyright (C) 2012-2013, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/device.h
+#include linux/err.h
+#include linux/i2c.h
+#include linux/list.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/platform_device.h
+#include linux/slab.h
+#include linux/types.h
+
+#include media/v4l2-async.h
+#include media/v4l2-device.h
+#include media/v4l2-subdev.h
+
+static bool match_i2c(struct device *dev, struct v4l2_async_hw_info *hw_dev)
+{
+   struct i2c_client *client = i2c_verify_client(dev);
+   return client 
+   hw_dev-bus_type == V4L2_ASYNC_BUS_I2C 
+   hw_dev-match.i2c.adapter_id == client-adapter-nr 
+   hw_dev-match.i2c.address == client-addr;
+}
+
+static bool match_platform(struct device *dev, struct v4l2_async_hw_info 
*hw_dev)
+{
+   return hw_dev-bus_type == V4L2_ASYNC_BUS_PLATFORM 
+   !strcmp(hw_dev-match.platform.name, dev_name(dev));
+}
+
+static LIST_HEAD(subdev_list);
+static LIST_HEAD(notifier_list);
+static DEFINE_MUTEX(list_lock);
+
+static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier 
*notifier,
+   struct 
v4l2_async_subdev_list *asdl)
+{
+   struct v4l2_subdev *sd = v4l2_async_to_subdev(asdl);
+   struct v4l2_async_subdev *asd = NULL;
+   bool (*match)(struct device *,
+ struct v4l2_async_hw_info *);
+
+   list_for_each_entry (asd, notifier-waiting, list) {
+   struct v4l2_async_hw_info *hw = asd-hw;
+
+   /* bus_type has been verified valid before */
+   switch (hw-bus_type) {
+   case V4L2_ASYNC_BUS_CUSTOM:
+   match = hw-match.custom.match;
+   if (!match)
+   /* Match always */
+   return asd;
+   break;
+   case V4L2_ASYNC_BUS_PLATFORM:
+   match = match_platform;
+   break;
+   case V4L2_ASYNC_BUS_I2C:
+   match = match_i2c;
+   break;
+   default:
+   /* Cannot happen, unless someone breaks us */
+   WARN_ON(true);
+   return NULL;
+   }
+
+   if (match  match(sd-dev, hw))
+   break;

[PATCH] dvb-apps: initial scan file de-NetAachen

2013-04-12 Thread Till Maas
Hi,

I created an initial scan file for the German provider Net Aachen (see
attachment).

Regards
Till
# HG changeset patch
# User Till Maas opensou...@till.name
# Date 1365783843 -7200
# Node ID fcdee9c712c94ac8b830dcbfec31ea2e5489adc3
# Parent  f3a70b206f0f809b53e2de7d77578d15b7d831cb
add util/scan/dvb-c/de-NetAachen

initial scan file for Net Aachen

diff --git a/util/scan/dvb-c/de-NetAachen b/util/scan/dvb-c/de-NetAachen
new file mode 100644
--- /dev/null
+++ b/util/scan/dvb-c/de-NetAachen
@@ -0,0 +1,47 @@
+#--
+# file automatically generated by w_scan
+# (http://wirbel.htpc-forum.de/w_scan/index2.html)
+#! w_scan 20120605 1 0 CABLE DE /w_scan
+# Manually adjusted by reducing whitespace between fec and mod
+#--
+# location and provider: Germany, Aachen, NetAachen, http://www.netaachen.de/
+# date (-mm-dd): 2013-04-11
+# provided by (opt): Till Maas opensou...@till.name
+#
+# C[2] [plp_id] [data_slice_id] [system_id] freq sr fec mod [# comment]
+#--
+C 11300 690 AUTO QAM256# NetCologne
+C 64200 690 AUTO QAM256# NetCologne
+C 61800 690 AUTO QAM256# NetCologne
+C 63400 690 AUTO QAM256# NetCologne
+C 62600 690 AUTO QAM256# NetCologne
+C 56200 690 AUTO QAM256# NetCologne
+C 40200 690 AUTO QAM256# NetCologne
+C 12100 690 AUTO QAM256# NetCologne
+C 57000 690 AUTO QAM256# NetCologne
+C 39400 690 AUTO QAM256# NetCologne
+C 58600 690 AUTO QAM256# NetCologne
+C 65000 690 AUTO QAM256# NetCologne
+C 65800 690 AUTO QAM256# NetCologne
+C 66600 690 AUTO QAM256# NetCologne
+C 67400 690 AUTO QAM256# NetCologne
+C 68200 690 AUTO QAM256# NetCologne
+C 69000 690 AUTO QAM256
+C 71400 690 AUTO QAM256
+C 60200 690 AUTO QAM256
+C 41000 690 AUTO QAM256# NetCologne
+C 41800 690 AUTO QAM256# NetCologne
+C 53000 690 AUTO QAM256# NetCologne
+C 53800 690 AUTO QAM256# NetCologne
+C 34600 690 AUTO QAM256# NetCologne
+C 33800 690 AUTO QAM256# NetCologne
+C 12900 690 AUTO QAM256# NetCologne
+C 35400 690 AUTO QAM64 # BetaDigital
+C 36200 690 AUTO QAM64 # BetaDigital
+C 37000 690 AUTO QAM64 # BetaDigital
+C 38600 690 AUTO QAM64 # BetaDigital
+C 37800 690 AUTO QAM64 # BetaDigital
+C 61000 690 AUTO QAM256
+C 57800 690 AUTO QAM256
+C 69800 690 AUTO QAM256
+C 70600 690 AUTO QAM256


[PATCH 3/3] rc: fix single line indentation of keymaps/Makefile

2013-04-12 Thread Antti Palosaari
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/rc/keymaps/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index 04baac4..5ab94ea 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -89,7 +89,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-tevii-nec.o \
rc-tivo.o \
rc-total-media-in-hand.o \
-   rc-total-media-in-hand-02.o \
+   rc-total-media-in-hand-02.o \
rc-trekstor.o \
rc-tt-1500.o \
rc-twinhan1027.o \
-- 
1.7.11.7

--
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 1/3] rc: add rc-reddo

2013-04-12 Thread Antti Palosaari
It is very similar than rc-msi-digivox-iii but new keytable is needed
as there is one existing scancode mapped to different button. Also that
one has less buttons.

NEC extended protocol with address 0x61d6.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/rc/keymaps/Makefile   |  1 +
 drivers/media/rc/keymaps/rc-reddo.c | 86 +
 include/media/rc-map.h  |  1 +
 3 files changed, 88 insertions(+)
 create mode 100644 drivers/media/rc/keymaps/rc-reddo.c

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index 7786619..04baac4 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -78,6 +78,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-hauppauge.o \
rc-rc6-mce.o \
rc-real-audio-220-32-keys.o \
+   rc-reddo.o \
rc-snapstream-firefly.o \
rc-streamzap.o \
rc-tbs-nec.o \
diff --git a/drivers/media/rc/keymaps/rc-reddo.c 
b/drivers/media/rc/keymaps/rc-reddo.c
new file mode 100644
index 000..b80b336
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-reddo.c
@@ -0,0 +1,86 @@
+/*
+ * MSI DIGIVOX mini III remote controller keytable
+ *
+ * Copyright (C) 2013 Antti Palosaari cr...@iki.fi
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License along
+ *with this program; if not, write to the Free Software Foundation, Inc.,
+ *51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include media/rc-map.h
+#include linux/module.h
+
+/*
+ * Derived from MSI DIGIVOX mini III remote (rc-msi-digivox-iii.c)
+ *
+ * Differences between these remotes are:
+ *
+ * 1) scancode 0x61d601 is mapped to different button:
+ *MSI DIGIVOX mini III   Source = KEY_VIDEO
+ *Reddo EPG = KEY_EPG
+ *
+ * 2) Reddo remote has less buttons. Missing buttons are: colored buttons,
+ *navigation buttons and main power button.
+ */
+
+static struct rc_map_table reddo[] = {
+   { 0x61d601, KEY_EPG }, /* EPG */
+   { 0x61d602, KEY_3 },
+   { 0x61d604, KEY_1 },
+   { 0x61d605, KEY_5 },
+   { 0x61d606, KEY_6 },
+   { 0x61d607, KEY_CHANNELDOWN }, /* CH- */
+   { 0x61d608, KEY_2 },
+   { 0x61d609, KEY_CHANNELUP },   /* CH+ */
+   { 0x61d60a, KEY_9 },
+   { 0x61d60b, KEY_ZOOM },/* Zoom */
+   { 0x61d60c, KEY_7 },
+   { 0x61d60d, KEY_8 },
+   { 0x61d60e, KEY_VOLUMEUP },/* Vol+ */
+   { 0x61d60f, KEY_4 },
+   { 0x61d610, KEY_ESC }, /* [back up arrow] */
+   { 0x61d611, KEY_0 },
+   { 0x61d612, KEY_OK },  /* [enter arrow] */
+   { 0x61d613, KEY_VOLUMEDOWN },  /* Vol- */
+   { 0x61d614, KEY_RECORD },  /* Rec */
+   { 0x61d615, KEY_STOP },/* Stop */
+   { 0x61d616, KEY_PLAY },/* Play */
+   { 0x61d617, KEY_MUTE },/* Mute */
+   { 0x61d643, KEY_POWER2 },  /* [red power button] */
+};
+
+static struct rc_map_list reddo_map = {
+   .map = {
+   .scan= reddo,
+   .size= ARRAY_SIZE(reddo),
+   .rc_type = RC_TYPE_NEC,
+   .name= RC_MAP_REDDO,
+   }
+};
+
+static int __init init_rc_map_reddo(void)
+{
+   return rc_map_register(reddo_map);
+}
+
+static void __exit exit_rc_map_reddo(void)
+{
+   rc_map_unregister(reddo_map);
+}
+
+module_init(init_rc_map_reddo)
+module_exit(exit_rc_map_reddo)
+
+MODULE_LICENSE(GPL);
+MODULE_AUTHOR(Antti Palosaari cr...@iki.fi);
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index f74ee6f..5d5d3a3 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -172,6 +172,7 @@ void rc_map_init(void);
 #define RC_MAP_RC5_TVrc-rc5-tv
 #define RC_MAP_RC6_MCE   rc-rc6-mce
 #define RC_MAP_REAL_AUDIO_220_32_KEYSrc-real-audio-220-32-keys
+#define RC_MAP_REDDO rc-reddo
 #define RC_MAP_SNAPSTREAM_FIREFLYrc-snapstream-firefly
 #define RC_MAP_STREAMZAP rc-streamzap
 #define RC_MAP_TBS_NEC   rc-tbs-nec
-- 
1.7.11.7

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

[PATCH 2/3] em28xx: map remote for 1b80:e425

2013-04-12 Thread Antti Palosaari
Map RC_MAP_REDDO to that device.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/em28xx/em28xx-cards.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 1d3866f..26ff1a7 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -1979,6 +1979,7 @@ struct em28xx_board em28xx_boards[] = {
.tuner_type= TUNER_ABSENT,
.tuner_gpio= maxmedia_ub425_tc,
.has_dvb   = 1,
+   .ir_codes  = RC_MAP_REDDO,
.def_i2c_bus   = 1,
.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
EM28XX_I2C_FREQ_400_KHZ,
-- 
1.7.11.7

--
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


cron job: media_tree daily build: WARNINGS

2013-04-12 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Fri Apr 12 19:00:17 CEST 2013
git branch: test
git hash:   81e096c8ac6a064854c2157e0bf802dc4906678c
gcc version:i686-linux-gcc (GCC) 4.7.2
host hardware:  x86_64
host os:3.8-3.slh.2-amd64

linux-git-arm-davinci: OK
linux-git-arm-exynos: WARNINGS
linux-git-arm-omap: WARNINGS
linux-git-blackfin: WARNINGS
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.31.14-i686: WARNINGS
linux-2.6.32.27-i686: WARNINGS
linux-2.6.33.7-i686: WARNINGS
linux-2.6.34.7-i686: WARNINGS
linux-2.6.35.9-i686: WARNINGS
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: WARNINGS
linux-3.2.37-i686: WARNINGS
linux-3.3.8-i686: WARNINGS
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-i686: OK
linux-3.9-rc1-i686: OK
linux-2.6.31.14-x86_64: WARNINGS
linux-2.6.32.27-x86_64: WARNINGS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: WARNINGS
linux-3.2.37-x86_64: WARNINGS
linux-3.3.8-x86_64: WARNINGS
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-x86_64: WARNINGS
linux-3.9-rc1-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API 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


[PATCH] solo6x10: Update the encoder mode on VIDIOC_S_FMT

2013-04-12 Thread Ismael Luceno

Signed-off-by: Ismael Luceno ismael.luc...@corp.bluecherry.net
---
 drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c 
b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
index 6147bb2..d132d3b 100644
--- a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
@@ -872,6 +872,7 @@ static int solo_enc_set_fmt_cap(struct file *file, void 
*priv,
if (pix-priv)
solo_enc-type = SOLO_ENC_TYPE_EXT;
 */
+   solo_update_mode(solo_enc);
return 0;
 }
 
-- 
1.8.2

--
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 RFC] [media] blackfin: add video display driver

2013-04-12 Thread Sylwester Nawrocki

Hello,

On 04/13/2013 01:52 AM, Scott Jiang wrote:

This is a bridge driver for blackfin diplay device.
It can work with ppi or eppi interface. DV timings
are supported.

Signed-off-by: Scott Jiangscott.jiang.li...@gmail.com
---
  drivers/media/platform/blackfin/Kconfig|   15 +-
  drivers/media/platform/blackfin/Makefile   |1 +
  drivers/media/platform/blackfin/bfin_display.c | 1151 
  include/media/blackfin/bfin_display.h  |   38 +
  4 files changed, 1203 insertions(+), 2 deletions(-)
  create mode 100644 drivers/media/platform/blackfin/bfin_display.c
  create mode 100644 include/media/blackfin/bfin_display.h

diff --git a/drivers/media/platform/blackfin/Kconfig 
b/drivers/media/platform/blackfin/Kconfig
index cc23997..8a8fd75 100644
--- a/drivers/media/platform/blackfin/Kconfig
+++ b/drivers/media/platform/blackfin/Kconfig
@@ -9,7 +9,18 @@ config VIDEO_BLACKFIN_CAPTURE
  To compile this driver as a module, choose M here: the
  module will be called bfin_capture.

+config VIDEO_BLACKFIN_DISPLAY
+   tristate Blackfin Video Display Driver
+   depends on VIDEO_V4L2  BLACKFIN  I2C
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ V4L2 bridge driver for Blackfin video display device.


Shouldn't it just be V4L2 output driver, why are you calling it bridge ?


+ Choose PPI or EPPI as its interface.
+
+ To compile this driver as a module, choose M here: the
+ module will be called bfin_display.
+
  config VIDEO_BLACKFIN_PPI
tristate
-   depends on VIDEO_BLACKFIN_CAPTURE
-   default VIDEO_BLACKFIN_CAPTURE
+   depends on VIDEO_BLACKFIN_CAPTURE || VIDEO_BLACKFIN_DISPLAY
+   default VIDEO_BLACKFIN_CAPTURE || VIDEO_BLACKFIN_DISPLAY
diff --git a/drivers/media/platform/blackfin/Makefile 
b/drivers/media/platform/blackfin/Makefile
index 30421bc..015c8f0 100644
--- a/drivers/media/platform/blackfin/Makefile
+++ b/drivers/media/platform/blackfin/Makefile
@@ -1,2 +1,3 @@
  obj-$(CONFIG_VIDEO_BLACKFIN_CAPTURE) += bfin_capture.o
+obj-$(CONFIG_VIDEO_BLACKFIN_DISPLAY) += bfin_display.o
  obj-$(CONFIG_VIDEO_BLACKFIN_PPI) += ppi.o
diff --git a/drivers/media/platform/blackfin/bfin_display.c 
b/drivers/media/platform/blackfin/bfin_display.c
new file mode 100644
index 000..d971d7b
--- /dev/null
+++ b/drivers/media/platform/blackfin/bfin_display.c
@@ -0,0 +1,1151 @@
+/*
+ * Analog Devices video display driver


Sounds a bit too generic.


+ *
+ * Copyright (c) 2011 Analog Devices Inc.


2011 - 2013 ?


+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#includelinux/completion.h
+#includelinux/delay.h
+#includelinux/errno.h
+#includelinux/fs.h
+#includelinux/i2c.h
+#includelinux/init.h
+#includelinux/interrupt.h
+#includelinux/io.h
+#includelinux/mm.h
+#includelinux/module.h
+#includelinux/platform_device.h
+#includelinux/slab.h
+#includelinux/time.h
+#includelinux/types.h
+
+#includemedia/v4l2-chip-ident.h
+#includemedia/v4l2-common.h
+#includemedia/v4l2-ctrls.h
+#includemedia/v4l2-device.h
+#includemedia/v4l2-ioctl.h
+#includemedia/videobuf2-dma-contig.h
+
+#includeasm/dma.h
+
+#includemedia/blackfin/bfin_display.h
+#includemedia/blackfin/ppi.h
+
+#define DISPLAY_DRV_NAMEbfin_display
+#define DISP_MIN_NUM_BUF2
+
+struct disp_format {
+   char *desc;
+   u32 pixelformat;
+   enum v4l2_mbus_pixelcode mbus_code;
+   int bpp; /* bits per pixel */
+   int dlen; /* data length for ppi in bits */
+};
+
+struct disp_buffer {
+   struct vb2_buffer vb;
+   struct list_head list;
+};
+
+struct disp_device {
+   /* capture device instance */


Shouldn't it be output device... ?


+   struct v4l2_device v4l2_dev;
+   /* v4l2 control handler */
+   struct v4l2_ctrl_handler ctrl_handler;


This handler seems to be unused, I couldn't find any code adding controls
to it. Any initialization of this handler is a dead code now. You probably
want to move that bits to a patch actually adding any controls.


+   /* device node data */
+   struct video_device *video_dev;
+   /* sub device instance */
+   struct v4l2_subdev *sd;
+   /* capture config */
+   struct bfin_display_config *cfg;
+   /* ppi interface */
+   struct ppi_if *ppi;
+   /* current output */
+   unsigned int cur_output;
+   /* current selected standard */
+   v4l2_std_id std;
+   /* current selected dv_timings */
+   struct v4l2_dv_timings dv_timings;
+   /* used to store pixel format */
+   struct v4l2_pix_format fmt;
+   /*