New ctrl framework also enumerates classes

2011-07-04 Thread Hans de Goede

Hi All,

One last thing before I really leave on vacation which just popped
in my mind as something which I had not mentioned yet.

The new ctrl framework also enumerates classes when enumerating
ctrls with the next flag. I wonder if this is intentional?

IOW if this is a feature or a bug?

Either way this confuses various userspace apps, gtk-v4l prints
warnings about an unknown control type, and v4l2ucp gets a very
messed up UI because of this change. Thus unless there are
really strong reasons to do this, I suggest we skip classes
when enumerating controls.

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


Re: New ctrl framework also enumerates classes

2011-07-04 Thread Hans Verkuil
On Monday, July 04, 2011 08:23:10 Hans de Goede wrote:
 Hi All,
 
 One last thing before I really leave on vacation which just popped
 in my mind as something which I had not mentioned yet.
 
 The new ctrl framework also enumerates classes when enumerating
 ctrls with the next flag. I wonder if this is intentional?

It's absolutely intentional. It's needed to produce the headers of the
tabs in e.g. qv4l2. It's been part of the spec for several years now.

 IOW if this is a feature or a bug?
 
 Either way this confuses various userspace apps, gtk-v4l prints
 warnings about an unknown control type,

It should just skip such types.

 and v4l2ucp gets a very
 messed up UI because of this change. Thus unless there are
 really strong reasons to do this, I suggest we skip classes
 when enumerating controls.

Those apps should be fixed. If apps see an unknown type, then they should
always just skip such controls (and later add support for it, of course).

Another control type (bitmask) will be merged soon as well, so the same
problem will occur with that, but this is all really an application bug.
Apps should be tested with vivi: that driver has all control types that we
have, so that's a good driver to test with.

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


Re: Kudos for the new vtl2 ctrls framework

2011-07-04 Thread Hans Verkuil
On Sunday, July 03, 2011 22:04:45 Hans de Goede wrote:
 Hi all,
 
 After making some serious use of it in the pwc driver cleanup
 I would like to thank Hans V. for all his hard work on the
 new ctrl framework.
 
 The clusters bit got a bit getting used to / but once I did
 it is great.
 
 Once you get it, it really makes sense to group certain ctrls
 into clusters which then get set in a single call to the driver,
 allowing more or less atomic handling of things like autofoo +
 foo changing. And in the pwc case also grouping the pan and
 tilt controls, which get set with a single usb command,
 so that with s_ex_ctrls an app can in theory do diagonal
 moving of the camera rather then stair case moving.
 
 Thanks Hans V.!

My pleasure!

I'll review the pwc patches this week. The pwc driver is used for some
astronomy work including things like long exposure settings. So I'll make
sure that that part is still working (or better, is working again since it
broken after the V4L1 removal).

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


Re: [PATCH] media: initial driver for ov5642 CMOS sensor

2011-07-04 Thread Guennadi Liakhovetski
Hi Angela

On Sun, 3 Jul 2011, angela wan wrote:

 Hi, Bastian,
 
Could the setting in ov5642.c like ov5642_default_regs_init and
 ov5642_default_regs_finalise adapt to different board? From my experience,
 ov5642 may have difference settings for differnt boards. So could we put the
 setting in another file instead of in the common driver?

No, that's not the solution, that we want. What we want is find the 
differences, understand them and learn to calculate them. So, for example, 
if you need different power management procedures, or if you feed the 
sensor with a different frequency clock, or if you use different lenses 
and your WB or gain or any other parameters differ then, we might have to 
use or add some platform parameters and verify them in the driver.

Thanks
Guennadi

 Best Regards,
 Angela Wan
 
 Application Processor Systems Engineering,
 Marvell Technology Group Ltd.
 
 
 On Tue, Jun 28, 2011 at 5:48 AM, Bastian Hecht hec...@googlemail.comwrote:
 
  2011/6/27 Laurent Pinchart laurent.pinch...@ideasonboard.com:
   Hi Bastian,
  
   Thanks for the patch.
  
   On Friday 24 June 2011 12:57:36 Bastian Hecht wrote:
   This is an initial driver release for the Omnivision 5642 CMOS sensor.
  
   Signed-off-by: Bastian Hecht hec...@gmail.com
   ---
  
   diff --git a/drivers/media/video/ov5642.c b/drivers/media/video/ov5642.c
   new file mode 100644
   index 000..3cdae97
   --- /dev/null
   +++ b/drivers/media/video/ov5642.c
   @@ -0,0 +1,1011 @@
   +/*
   + * Driver for OV5642 CMOS Image Sensor from Omnivision
   + *
   + * Copyright (C) 2011, Bastian Hecht hec...@gmail.com
   + *
   + * Based on Sony IMX074 Camera Driver
   + * Copyright (C) 2010, Guennadi Liakhovetski g.liakhovet...@gmx.de
   + *
   + * Based on Omnivision OV7670 Camera Driver
   + * Copyright (C) 2006-7 Jonathan Corbet cor...@lwn.net
   + *
   + * 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/delay.h
   +#include linux/i2c.h
   +#include linux/slab.h
   +#include linux/videodev2.h
   +
   +#include media/soc_camera.h
   +#include media/soc_mediabus.h
   +#include media/v4l2-chip-ident.h
   +#include media/v4l2-subdev.h
   +
   +/* OV5642 registers */
   +#define REG_CHIP_ID_HIGH 0x300a
   +#define REG_CHIP_ID_LOW  0x300b
   +
   +#define REG_WINDOW_START_X_HIGH  0x3800
   +#define REG_WINDOW_START_X_LOW   0x3801
   +#define REG_WINDOW_START_Y_HIGH  0x3802
   +#define REG_WINDOW_START_Y_LOW   0x3803
   +#define REG_WINDOW_WIDTH_HIGH0x3804
   +#define REG_WINDOW_WIDTH_LOW 0x3805
   +#define REG_WINDOW_HEIGHT_HIGH   0x3806
   +#define REG_WINDOW_HEIGHT_LOW0x3807
   +#define REG_OUT_WIDTH_HIGH   0x3808
   +#define REG_OUT_WIDTH_LOW0x3809
   +#define REG_OUT_HEIGHT_HIGH  0x380a
   +#define REG_OUT_HEIGHT_LOW   0x380b
   +#define REG_OUT_TOTAL_WIDTH_HIGH 0x380c
   +#define REG_OUT_TOTAL_WIDTH_LOW  0x380d
   +#define REG_OUT_TOTAL_HEIGHT_HIGH0x380e
   +#define REG_OUT_TOTAL_HEIGHT_LOW 0x380f
   +
   +/*
   + * define standard resolution.
   + * Works currently only for up to 720 lines
   + * eg. 320x240, 640x480, 800x600, 1280x720, 2048x720
   + */
   +
   +#define OV5642_WIDTH 1280
   +#define OV5642_HEIGHT720
   +#define OV5642_TOTAL_WIDTH   3200
   +#define OV5642_TOTAL_HEIGHT  2000
   +#define OV5642_SENSOR_SIZE_X 2592
   +#define OV5642_SENSOR_SIZE_Y 1944
   +
   +struct regval_list {
   + u16 reg_num;
   + u8 value;
   +};
   +
   +static struct regval_list ov5642_default_regs_init[] = {
   + { 0x3103, 0x93 },
   + { 0x3008, 0x82 },
   + { 0x3017, 0x7f },
   + { 0x3018, 0xfc },
   + { 0x3810, 0xc2 },
   + { 0x3615, 0xf0 },
   + { 0x3000, 0x0  },
   + { 0x3001, 0x0  },
   + { 0x3002, 0x0  },
   + { 0x3003, 0x0  },
   + { 0x3004, 0xff },
   + { 0x3030, 0x2b },
   + { 0x3011, 0x8  },
   + { 0x3010, 0x10 },
   + { 0x3604, 0x60 },
   + { 0x3622, 0x60 },
   + { 0x3621, 0x9  },
   + { 0x3709, 0x0  },
   + { 0x4000, 0x21 },
   + { 0x401d, 0x22 },
   + { 0x3600, 0x54 },
   + { 0x3605, 0x4  },
   + { 0x3606, 0x3f },
   + { 0x3c01, 0x80 },
   + { 0x300d, 0x22 },
   + { 0x3623, 0x22 },
   + { 0x5000, 0x4f },
   + { 0x5020, 0x4  },
   + { 0x5181, 0x79 },
   + { 0x5182, 0x0  },
   + { 0x5185, 0x22 },
   + { 0x5197, 0x1  },
   + { 0x5500, 0xa  },
   + { 0x5504, 0x0  },
   + { 0x5505, 0x7f },
   + { 0x5080, 0x8  },
   + { 0x300e, 0x18 },
   + { 0x4610, 0x0  },
   + { 0x471d, 0x5  },
   + { 0x4708, 0x6  },
   + { 0x370c, 0xa0 },
   + { 0x5687, 0x94 },
   + { 0x501f, 0x0  },

Re: [GIT PATCHES FOR 3.1] New SE401 driver + major pwc driver cleanup

2011-07-04 Thread Hans Verkuil
Hi Hans,

I have some notes:

On Sunday, July 03, 2011 22:00:39 Hans de Goede wrote:
 Hi All,
 
 I'm happy to present my latest webcam work to you:
 
 I could not just stand by watching the old v4l1 se401 driver
 (which has been broken for a long while btw) get removed
 from the kernel, without writing a replacement, so I'm
 happy to present a new, actually working, gspca based
 v4l2 driver for se401 based webcams :)
 
 I've also wanted to do some much needed cleanups to the
 pwc driver for a long while. When I finally started with
 this I ended up with just replacing large parts with
 the new v4l2 framework, so after this patch set pwc
 now features:
 -videobuf2 for buffer management
 -ctrls handled by the control framework, including proper
   setting inactive of foo controls when autofoo is on, etc.
 -new v4l2 controls for pan/tilt on models with pan/tilt
   to replace the non standard sysfs interface for this
 
 May I also point your attention to the
 feature-removal-schedule commit, which adds a whole bunch
 of custom pwc API's / ioctls for removal, since we can
 handle this all fine with v4l2. If you think some of
 these should not be removed speak up now, or hold
 your silence for ever :)
 
 The following changes since commit 0c2ec360f0228bbc0c0eb6f115839d39fbbd9c61:
 
[media] v4l2-event.h: add overview documentation to the header 
(2011-07-01 20:54:03 -0300)
 
 are available in the git repository at:
git://linuxtv.org/hgoede/gspca.git media-for_v3.1
 
 Hans Verkuil (1):
[media] v4l2-ctrls.c: add support for 
V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK
 
 Hans de Goede (22):
videodev2.h Add SE401 compressed RGB format
gspca: reset image_len to 0 on LAST_PACKET when discarding frame
gspca: Add new se401 camera driver
gspca_sunplus: Fix streaming on logitech quicksmart 420
gspca: s/strncpy/strlcpy/
pwc: better usb disconnect handling
pwc: Remove a bunch of bogus sanity checks / don't return EFAULT 
wrongly
pwc: remove __cplusplus guards from private header
pwc: Replace private buffer management code with videobuf2
pwc: Fix non CodingStyle compliant 3 space indent in pwc.h
pwc: Get rid of error_status and unplugged variables
pwc: Remove some unused PWC_INT_PIPE left overs
pwc: Make power-saving a per device option
pwc: Move various initialization to driver load and / or stream start
pwc: Allow multiple opens

Snippet from this patch:

@@ -727,6 +740,9 @@ static int pwc_streamon(struct file *file, void *fh, enum 
v4l2_buf_type i)
if (!pdev-udev)
return -ENODEV;
 
+   if (pdev-capt_file != file)
+   return -EBUSY;
+
return vb2_streamon(pdev-vb_queue, i);
 }

This really needs to be codified in vb2. I'll see if I can do some work on 
this. Drivers need to keep track of this themselves at the moment, which 
varying degrees of success :-)

pwc: properly allocate dma-able memory for ISO buffers
pwc: Replace control code with v4l2-ctrls framework

The private controls should get their own range in videodev2.h. Something 
like:

/* Reserve range USER | 0x1000 to USER | 0x1020 for the pwc drivers */
#define V4L2_CID_USER_PWC_BASE  (V4L2_CTRL_CLASS_USER | 0x1000)

The control IDs themselves should be either added to videodev2.h or to a 
public pwc.h header.

I also wonder if most/all of these controls are not better done as camera 
controls (CLASS_CAMERA).

Regarding auto-whitebalance: this 'overwrites' the standard auto-whitebalance 
control: should we perhaps change the standard awb control instead to a menu? 
Or should we add a separate menu control for the lighting condition?

With respect to the autocluster part: that needs to be revisited. We need to 
clearly define acceptable behaviors on the part of the driver and codify that 
in the autocluster support of the framework. You have to do way too much work 
in the driver right now.

None of this prevents this series from being merged, BTW.

Another thing that needs to be looked at is the use of the priv field in
VIDIOC_S_FMT:

if (f-fmt.pix.priv) {
compression = (f-fmt.pix.priv  PWC_QLT_MASK)  
PWC_QLT_SHIFT;
snapshot = !!(f-fmt.pix.priv  PWC_FPS_SNAPSHOT);
fps = (f-fmt.pix.priv  PWC_FPS_FRMASK)  PWC_FPS_SHIFT;
if (fps == 0)
fps = pdev-vframes;
}

I think at least the fps part should be done through G/S_PARM. What the others 
do is not clear to me.

Regards,

Hans

pwc: Allow dqbuf / read to complete while waiting for controls
pwc: Add v4l2 controls for pan/tilt on Logitech QuickCam Orbit/Sphere
pwc: Add a bunch of pwc custom API to feature-removal-schedule.txt
pwc: Enable power-management by default on tested models
pwc: clean-up header files
 
   Documentation/DocBook/media/v4l/pixfmt.xml |5 +
   

Re: Some comments on the new autocluster patches

2011-07-04 Thread Hans Verkuil
On Saturday, July 02, 2011 16:31:47 Hans de Goede wrote:
 Hi,
 
 On 07/02/2011 01:10 PM, Hans Verkuil wrote:
  On Saturday, July 02, 2011 12:28:35 Hans de Goede wrote:
  Hi,
 
  snip snip snip
 
  Ok, thinking about this some more and reading Hans V's comments
  I think that the current code in Hans V's core8c branch is fine,
  and should go to 3.1 (rather then be delayed to 3.2).
 
  As for the fundamental question what to do with foo
  controls when autofoo goes from auto to manual, as discussed
  there are 2 options:
  1) Restore the last known / previous manual setting
  2) Keep foo at the current setting, iow the last setting
   configured by autofoo
 
  Or option 3:
 
  Just don't report the automatic foo values at all. What possible purpose
  does it serve?
 Reporting should be seen separate of what to do with the actual
 setting of for example gain as in use by the device when autogain
 gets turned off, that is what I'm talking about here, when autogain
 gets turned off (iow gain gets set to manual) there are 2 and only
 2 options
 
 1) leave the gain at the value last set by the devices
 autogain function (this may not be supported on all hardware)
 2) restore the last known manual gain setting
 
 What we report or not report for gain while autogain is active
 is irrelevant for this choice, when switching to manual we can
 either leave gain as is, or we restore the last known setting.
 Independent of any values we may have reported.

It is relevant. Take an application that saves the current state of all 
controls and restores it the next time it is started. If you report the 
device's autogain value instead of the manual gain, then that manual gain 
value is lost. I consider this a major drawback.
 
   It is my impression that drivers implement it 'just because
   they can', and not because it is meaningful.
 
 Well it is drivers responsibility to export hardware functionality
 (in a standardized manner), then it is up to applications whether
 they use it or not. And it is actually quite meaning full, you
 are very much thinking TV and not webcams here, being able to
 see that the autofoo is actually doing something, and what
 it is doing is very useful for webcams. For example maybe it is
 choosing a low exposure (to get highframerate) high gain, which
 leads to more noise in the picture then the user wants
 
 webcams are like photography, you've a shutter and a sensitivity
 (iso) setting being able to see what a camera chooses in full
 auto mode is quite useful.

OK, but it is not useful that this means that you don't see the manual value 
anymore.

  I'm not aware of any application that actually refreshes e.g. gain values
  when autogain is on, so end-users never see it anyway.
 
 v4l2ucp has an option to update the ctrl readings every 1 / 2 / 5
 seconds. And I use this often to track what the autofoo is doing
 and / or to verify that it doing anything at all.

OK, good to know.

  But I think we should stop supporting volatile writable controls.
 
 NACK, and note that we already don't do that, what we do is switch
 a control from volatile read only (inactive) to non volatile rw-mode
 and back. The only question is what to do at the transition.

No, the question is also what to return.

How many 'autofoo' controls are there anyway?

V4L2_CID_AUTO_WHITE_BALANCE
V4L2_CID_AUTOGAIN
V4L2_CID_EXPOSURE_AUTO
V4L2_CID_AUTOBRIGHTNESS
V4L2_CID_HUE_AUTO

Those last two are used in only two drivers (gspca and uvc respectively).

The first three would require four extra read-only volatile controls:

V4L2_CID_AUTOWB_RED_BALANCE
V4L2_CID_AUTOWB_BLUE_BALANCE
V4L2_CID_AUTOGAIN_GAIN
V4L2_CID_AUTOEXP_EXPOSURE

Simple and straightforward. Applications can show the manual value and the 
autofoo value together so you can compare them easily. No unexpected 
transitions since turning off the autofoo will restore the manual foo value.

And apps that save/restore controls will always get/set the proper manual foo 
values.

The most difficult part will be to come up with a decent description of these 
controls:

Gain, Automatic Value
Gain, Computed Value
Gain, Current Value
Gain, Current

Hmm, those last two aren't so bad since that would fit equally whether 
autogain is on or off.

That suggests better CID naming as well:

V4L2_CID_RED_BALANCE_CUR (Red Balance, Current)
V4L2_CID_BLUE_BALANCE_CUR (Blue Balance, Current)
V4L2_CID_GAIN_CUR (Gain, Current)
V4L2_CID_EXPOSURE_CUR (Exposure, Current)

Simple, straightforward, no confusion.

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


Re: [PATCH 4/5] cxd2099: Fix compilation of ngene/ddbridge for DVB_CXD2099=n

2011-07-04 Thread Bjørn Mork
Oliver Endriss o.endr...@gmx.de writes:

 Fix compilation of ngene/ddbridge for DVB_CXD2099=n.

 Note: Bug was introduced by commit 'cxd2099: Update to latest version'.

Shouldn't that patch instead be fixed and resubmitted?


Bjørn

--
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 1/2] Add driver for Aptina Micron mt9p031 sensor.

2011-07-04 Thread javier Martin
Hi, Laurent.
How is it going?

Is there any chance these changes to be included for next release?
We are afraid that changes in the framework may turn the patches useless.

Thank you.

-- 
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
--
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 15/16] ngene: Update for latest cxd2099

2011-07-04 Thread Issa Gorissen
From: Oliver Endriss o.endr...@gmx.de

 Modifications for latest cxd2099.
 
 Signed-off-by: Oliver Endriss o.endr...@gmx.de
 ---
  drivers/media/dvb/ngene/ngene-core.c |9 -
  1 files changed, 8 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/media/dvb/ngene/ngene-core.c
b/drivers/media/dvb/ngene/ngene-core.c
 index fa4b3eb..df0f0bd 100644
 --- a/drivers/media/dvb/ngene/ngene-core.c
 +++ b/drivers/media/dvb/ngene/ngene-core.c
 @@ -1582,11 +1582,18 @@ static int init_channels(struct ngene *dev)
   return 0;
  }
  
 +static struct cxd2099_cfg cxd_cfg = {
 + .bitrate = 62000,


bitrate's never used anywhere (yet ?), why keeping it ?

--
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 13/16] cxd2099: Update to latest version

2011-07-04 Thread Issa Gorissen
On 03/07/2011 19:00, Oliver Endriss wrote:
 @@ -284,53 +313,84 @@ static int init(struct cxd *ci)
   CHK_ERROR(write_reg(ci, 0x08, 0x28));
   CHK_ERROR(write_reg(ci, 0x14, 0x20));
  
 - CHK_ERROR(write_reg(ci, 0x09, 0x4D)); /* Input Mode C, BYPass 
 Serial, TIVAL = low, MSB */
 + /* CHK_ERROR(write_reg(ci, 0x09, 0x4D));*/ /* Input Mode C, 
 BYPass Serial, TIVAL = low, MSB */
   CHK_ERROR(write_reg(ci, 0x0A, 0xA7)); /* TOSTRT = 8, Mode B 
 (gated clock), falling Edge, Serial, POL=HIGH, MSB */
  
 - /* Sync detector */
   CHK_ERROR(write_reg(ci, 0x0B, 0x33));
   CHK_ERROR(write_reg(ci, 0x0C, 0x33));
  
   CHK_ERROR(write_regm(ci, 0x14, 0x00, 0x0F));
   CHK_ERROR(write_reg(ci, 0x15, ci-clk_reg_b));
   CHK_ERROR(write_regm(ci, 0x16, 0x00, 0x0F));
 - CHK_ERROR(write_reg(ci, 0x17, ci-clk_reg_f));
 + CHK_ERROR(write_reg(ci, 0x17,ci-clk_reg_f));
  
 - CHK_ERROR(write_reg(ci, 0x20, 0x28)); /* Integer Divider, 
 Falling Edge, Internal Sync, */
 - CHK_ERROR(write_reg(ci, 0x21, 0x00)); /* MCLKI = TICLK/8 */
 - CHK_ERROR(write_reg(ci, 0x22, 0x07)); /* MCLKI = TICLK/8 */
 + if (ci-cfg.clock_mode) {
 + if (ci-cfg.polarity) {
 + CHK_ERROR(write_reg(ci, 0x09, 0x6f));
 + } else {
 + CHK_ERROR(write_reg(ci, 0x09, 0x6d));
 + }
 + CHK_ERROR(write_reg(ci, 0x20, 0x68));
 + CHK_ERROR(write_reg(ci, 0x21, 0x00));
 + CHK_ERROR(write_reg(ci, 0x22, 0x02));

When clock_mode = 1, you set MKCLI to 9MHz. Comments in this code would
be really nice. Used by ddbrige it seems.

 + } else {
 + if (ci-cfg.polarity) {
 + CHK_ERROR(write_reg(ci, 0x09, 0x4f));
 + } else {
 + CHK_ERROR(write_reg(ci, 0x09, 0x4d));
 + }
  
 + CHK_ERROR(write_reg(ci, 0x20, 0x28));
 + CHK_ERROR(write_reg(ci, 0x21, 0x00));
 + CHK_ERROR(write_reg(ci, 0x22, 0x07));
 + }

When clock_mode = 0, input ts is in serial mode C, MCLKI = TICLK / 8 ;
why not set register 0x20 to 0x8 only ? Also, no need to set 0x21 nor
0x22 which are only for serial input mode D. And only used by ngene it
seems. Is TICLK equal to the bitrate variable (6200) ? If yes, then
MCLKI can only reach a value of ~7,8MHz, which is not the maximum speed
of CAMs. Is this on purpose ? Ngene chip limitation ?
--
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: [DVB] Possible regression in stb6100 module for DVBS2 transponders

2011-07-04 Thread Issa Gorissen
On 01/07/2011 10:44, Sébastien RAILLARD (COEXSI) wrote:
 Dear Manu,

 I think there is a regression in your patch from December 2010 regarding the
 stb6100 module.
 With the latest version of stb6100 published in media_build git branch, we
 can't tune the TT-S2-3200 on some DVBS2 transponders like Hotbird 13E
 11681-H-27500 or Hotbird 13E 12692-H-27500.
 After reverting to the previous stb6100_set_frequency function, it's working
 fine.
 So, there is maybe in issue in the last December code refactoring.

 Reference of the patch: [media] stb6100: Improve tuner performance
 http://git.linuxtv.org/media_tree.git?a=history;f=drivers/media/dvb/frontend
 s/stb6100.c;h=bc1a8af4f6e105181670ee33ebe111f98425e0ff;hb=HEAD

 See below for the code removed from the stb6100.c file (the
 stb6100_set_frequency function) and the code added (the previous
 stb6100_set_frequency function and the stb6100_write_regs function).

 Best regards,
 Sebastien.

Reported back in may
[http://www.mail-archive.com/linux-media@vger.kernel.org/msg31334.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


Re: [PATCH] v4l: Don't register media entities for subdev device nodes

2011-07-04 Thread Michael Jones
On 04/11/2011 04:26 PM, Laurent Pinchart wrote:
 Subdevs already have their own entity, don't register as second one when
 registering the subdev device node.
 
 Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  drivers/media/video/v4l2-dev.c |   15 ++-
  1 files changed, 10 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
 index 498e674..6dc7196 100644
 --- a/drivers/media/video/v4l2-dev.c
 +++ b/drivers/media/video/v4l2-dev.c
 @@ -389,7 +389,8 @@ static int v4l2_open(struct inode *inode, struct file 
 *filp)
   video_get(vdev);
   mutex_unlock(videodev_lock);
  #if defined(CONFIG_MEDIA_CONTROLLER)
 - if (vdev-v4l2_dev  vdev-v4l2_dev-mdev) {
 + if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
 + vdev-vfl_type != VFL_TYPE_SUBDEV) {
   entity = media_entity_get(vdev-entity);
   if (!entity) {
   ret = -EBUSY;
 @@ -415,7 +416,8 @@ err:
   /* decrease the refcount in case of an error */
   if (ret) {
  #if defined(CONFIG_MEDIA_CONTROLLER)
 - if (vdev-v4l2_dev  vdev-v4l2_dev-mdev)
 + if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
 + vdev-vfl_type != VFL_TYPE_SUBDEV)
   media_entity_put(entity);
  #endif
   video_put(vdev);
 @@ -437,7 +439,8 @@ static int v4l2_release(struct inode *inode, struct file 
 *filp)
   mutex_unlock(vdev-lock);
   }
  #if defined(CONFIG_MEDIA_CONTROLLER)
 - if (vdev-v4l2_dev  vdev-v4l2_dev-mdev)
 + if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
 + vdev-vfl_type != VFL_TYPE_SUBDEV)
   media_entity_put(vdev-entity);
  #endif
   /* decrease the refcount unconditionally since the release()
 @@ -686,7 +689,8 @@ int __video_register_device(struct video_device *vdev, 
 int type, int nr,
  
  #if defined(CONFIG_MEDIA_CONTROLLER)
   /* Part 5: Register the entity. */
 - if (vdev-v4l2_dev  vdev-v4l2_dev-mdev) {
 + if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
 + vdev-vfl_type != VFL_TYPE_SUBDEV) {
   vdev-entity.type = MEDIA_ENT_T_DEVNODE_V4L;
   vdev-entity.name = vdev-name;
   vdev-entity.v4l.major = VIDEO_MAJOR;
 @@ -733,7 +737,8 @@ void video_unregister_device(struct video_device *vdev)
   return;
  
  #if defined(CONFIG_MEDIA_CONTROLLER)
 - if (vdev-v4l2_dev  vdev-v4l2_dev-mdev)
 + if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
 + vdev-vfl_type != VFL_TYPE_SUBDEV)
   media_device_unregister_entity(vdev-entity);
  #endif
  

Hi Laurent,

If v4l2_subdev has a 'struct media_entity' inside of its 'struct
video_device' member, why does it need a media_entity of its own?
Shouldn't we eliminate v4l2_subdev.entity and always just use
v4l2_subdev.devnode.entity where it is needed?  Or do they have 2
different purposes?

-Michael

MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner, Erhard Meier
--
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] v4l: Don't register media entities for subdev device nodes

2011-07-04 Thread Laurent Pinchart
Hi Michael,

On Monday 04 July 2011 15:11:21 Michael Jones wrote:
 On 04/11/2011 04:26 PM, Laurent Pinchart wrote:
  Subdevs already have their own entity, don't register as second one when
  registering the subdev device node.
  
  Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
  ---
  
   drivers/media/video/v4l2-dev.c |   15 ++-
   1 files changed, 10 insertions(+), 5 deletions(-)
  
  diff --git a/drivers/media/video/v4l2-dev.c
  b/drivers/media/video/v4l2-dev.c index 498e674..6dc7196 100644
  --- a/drivers/media/video/v4l2-dev.c
  +++ b/drivers/media/video/v4l2-dev.c
  @@ -389,7 +389,8 @@ static int v4l2_open(struct inode *inode, struct file
  *filp)
  
  video_get(vdev);
  mutex_unlock(videodev_lock);
   
   #if defined(CONFIG_MEDIA_CONTROLLER)
  
  -   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev) {
  +   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
  +   vdev-vfl_type != VFL_TYPE_SUBDEV) {
  
  entity = media_entity_get(vdev-entity);
  if (!entity) {
  
  ret = -EBUSY;
  
  @@ -415,7 +416,8 @@ err:
  /* decrease the refcount in case of an error */
  if (ret) {
   
   #if defined(CONFIG_MEDIA_CONTROLLER)
  
  -   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev)
  +   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
  +   vdev-vfl_type != VFL_TYPE_SUBDEV)
  
  media_entity_put(entity);
   
   #endif
   
  video_put(vdev);
  
  @@ -437,7 +439,8 @@ static int v4l2_release(struct inode *inode, struct
  file *filp)
  
  mutex_unlock(vdev-lock);
  
  }
   
   #if defined(CONFIG_MEDIA_CONTROLLER)
  
  -   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev)
  +   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
  +   vdev-vfl_type != VFL_TYPE_SUBDEV)
  
  media_entity_put(vdev-entity);
   
   #endif
   
  /* decrease the refcount unconditionally since the release()
  
  @@ -686,7 +689,8 @@ int __video_register_device(struct video_device
  *vdev, int type, int nr,
  
   #if defined(CONFIG_MEDIA_CONTROLLER)
   
  /* Part 5: Register the entity. */
  
  -   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev) {
  +   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
  +   vdev-vfl_type != VFL_TYPE_SUBDEV) {
  
  vdev-entity.type = MEDIA_ENT_T_DEVNODE_V4L;
  vdev-entity.name = vdev-name;
  vdev-entity.v4l.major = VIDEO_MAJOR;
  
  @@ -733,7 +737,8 @@ void video_unregister_device(struct video_device
  *vdev)
  
  return;
   
   #if defined(CONFIG_MEDIA_CONTROLLER)
  
  -   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev)
  +   if (vdev-v4l2_dev  vdev-v4l2_dev-mdev 
  +   vdev-vfl_type != VFL_TYPE_SUBDEV)
  
  media_device_unregister_entity(vdev-entity);
   
   #endif
 
 Hi Laurent,
 
 If v4l2_subdev has a 'struct media_entity' inside of its 'struct
 video_device' member, why does it need a media_entity of its own?
 Shouldn't we eliminate v4l2_subdev.entity and always just use
 v4l2_subdev.devnode.entity where it is needed?  Or do they have 2
 different purposes?

Not all subdevs have a devnode. struct video_device is embedded in struct 
v4l2_subdev, but it's not used for devnode-less subdevs.

-- 
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: [ RFC PATCH 0/8] RFC for Media Controller capture driver for DM365

2011-07-04 Thread Laurent Pinchart
Hi Manjunath,

On Monday 04 July 2011 07:58:06 Hadli, Manjunath wrote:
 On Thu, Jun 30, 2011 at 19:27:36, Sakari Ailus wrote:

[snip]

  I understand that not all the blocks are there. Are there any major
  functional differences between those in Davinci and those in OMAP 3?
  Could the OMAP 3 ISP driver made support Davinci ISP as well?
 
 Yes, there are a lot of major differences between OMAP3 and Dm365/Dm355,
 both in terms of features, there IP, and the software interface, including
 all the registers which are entirely different. The closest omap3 would
 come to is only to DM6446. I do not think OMAP3 driver can be made to
 support Dm355 and Dm365. It is good to keep the OMAP3 neat and clean to
 cater for OMAP4 and beyond, and keep the Davinci family separate. The
 names might look similar and hence confusing for you, but the names can as
 well be made the same as Dm365 blocks like ISIF and IPIPE and IPIPEIF
 which are different.

The DM6446 ISP is very similar to the OMAP3 ISP, and thus quite different from 
the DM355/365 ISPs. Should the DM6446 be supported by the OMAP3 ISP driver, 
and the DM355/365 by this driver ?

  There are number of possible improvements that still should be made to
  the OMAP 3 ISP driver so this way both of the driver would easily get
  them. To mention some:
  
  - Multiple output pipeline
  - Switch to videobuf2
  - Switch to GENIRQ
 
 Sure. There is definitely a design element convergence, and overtime I
 think some of these would get into the core v4l2 infrastructure.

-- 
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 1/5] drivers/media/video/cx231xx/cx231xx-cards.c: add missing kfree

2011-07-04 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk

Clear the cx231xx_devused variable and free dev in the error handling code,
as done in the error handling code nearby.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@r@
identifier x;
@@

kfree(x)

@@
identifier r.x;
expression E1!=0,E2,E3,E4;
statement S;
@@

(
if (+...x...+) S
|
if (...) { ... when != kfree(x)
   when != if (...) { ... kfree(x); ... }
   when != x = E3
* return E1;
}
... when != x = E2
if (...) { ... when != x = E4
 kfree(x); ... return ...; }
)
// /smpl

Signed-off-by: Julia Lawall ju...@diku.dk

---
 drivers/media/video/cx231xx/cx231xx-cards.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c 
b/drivers/media/video/cx231xx/cx231xx-cards.c
index 2270381..c46dca9 100644
--- a/drivers/media/video/cx231xx/cx231xx-cards.c
+++ b/drivers/media/video/cx231xx/cx231xx-cards.c
@@ -1051,6 +1051,9 @@ static int cx231xx_usb_probe(struct usb_interface 
*interface,
if (assoc_desc-bFirstInterface != ifnum) {
cx231xx_err(DRIVER_NAME : Not found 
matching IAD interface\n);
+   cx231xx_devused = ~(1  nr);
+   kfree(dev);
+   dev = NULL;
return -ENODEV;
}
 

--
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/5] drivers/media/video: add missing kfree

2011-07-04 Thread Julia Lawall
From: Julia Lawall ju...@diku.dk

Free the recently allocated qcam in each case.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@r@
identifier x;
@@

kfree(x)

@@
identifier r.x;
expression E1!=0,E2,E3,E4;
statement S;
@@

(
if (+...x...+) S
|
if (...) { ... when != kfree(x)
   when != if (...) { ... kfree(x); ... }
   when != x = E3
* return E1;
}
... when != x = E2
if (...) { ... when != x = E4
 kfree(x); ... return ...; }
)
// /smpl

Signed-off-by: Julia Lawall ju...@diku.dk

---
 drivers/media/video/bw-qcam.c |1 +
 drivers/media/video/c-qcam.c  |1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index c119350..0aad9cc 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -895,6 +895,7 @@ static struct qcam *qcam_init(struct parport *port)
 
if (v4l2_device_register(NULL, v4l2_dev)  0) {
v4l2_err(v4l2_dev, Could not register v4l2_device\n);
+   kfree(qcam);
return NULL;
}
 
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 24fc009..351b2db 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -752,6 +752,7 @@ static struct qcam *qcam_init(struct parport *port)
 
if (v4l2_device_register(NULL, v4l2_dev)  0) {
v4l2_err(v4l2_dev, Could not register v4l2_device\n);
+   kfree(qcam);
return NULL;
}
 

--
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: [Linaro-mm-sig] [PATCH 08/10] mm: cma: Contiguous Memory Allocator added

2011-07-04 Thread Arnd Bergmann
On Monday 04 July 2011, Ankita Garg wrote:
  It still sounds to me that this can be done using the NUMA properties
  that Linux already understands, and teaching more subsystems about it,
  but maybe the memory hotplug developers have already come up with
  another scheme. The way that memory hotplug and CMA choose their
  memory regions certainly needs to take both into account. As far as
  I can see there are both conflicting and synergistic effects when
  you combine the two.
  
 
 Recently, we proposed a generic 'memory regions' framework to exploit
 the memory power management capabilities on the embedded boards. Think
 of some of the above CMA requirements could be met by this fraemwork.
 One of the main goals of regions is to make the VM aware of the hardware
 memory boundaries, like bank. For managing memory power consumption,
 memory regions are created aligned to the hardware granularity at which
 the power can be managed (ie, the memory power consumption operations
 like on/off can be performed). If attributed are associated with each of
 these regions, some of these regions could be marked as CMA-only,
 ensuring that only movable and per-bank memory is allocated. More
 details on the design can be found here:
 
 http://lkml.org/lkml/2011/5/27/177
 http://lkml.org/lkml/2011/6/29/202
 http://lwn.net/Articles/446493/

Thanks for the pointers, that is exactly what I was looking for.

Arnd
--
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 PATCH 0/8] RFC for Media Controller capture driver for DM365

2011-07-04 Thread Hadli, Manjunath
Thank you Laurent.

On Mon, Jul 04, 2011 at 18:52:37, Laurent Pinchart wrote:
 Hi Manjunath,
 
 On Monday 04 July 2011 07:58:06 Hadli, Manjunath wrote:
  On Thu, Jun 30, 2011 at 19:27:36, Sakari Ailus wrote:
 
 [snip]
 
   I understand that not all the blocks are there. Are there any major 
   functional differences between those in Davinci and those in OMAP 3?
   Could the OMAP 3 ISP driver made support Davinci ISP as well?
  
  Yes, there are a lot of major differences between OMAP3 and 
  Dm365/Dm355, both in terms of features, there IP, and the software 
  interface, including all the registers which are entirely different. 
  The closest omap3 would come to is only to DM6446. I do not think 
  OMAP3 driver can be made to support Dm355 and Dm365. It is good to 
  keep the OMAP3 neat and clean to cater for OMAP4 and beyond, and keep 
  the Davinci family separate. The names might look similar and hence 
  confusing for you, but the names can as well be made the same as Dm365 
  blocks like ISIF and IPIPE and IPIPEIF which are different.
 
 The DM6446 ISP is very similar to the OMAP3 ISP, and thus quite different 
 from the DM355/365 ISPs. Should the DM6446 be supported by the OMAP3 ISP 
 driver, and the DM355/365 by this driver ?

DM6446 capture IP is in some respects similar to OMAP3 for some features, but 
there are a large number of differences also (MMU, VRFB, a lot of display 
interfaces etc). Having a single driver catering to  
Since DM6446 and OMAP3 is going to be unwieldy.
Also, DM6446 belongs to the Davinci family of chips, it should be clubbed with 
the other Davinci SoCs as it will simplify a lot of other things including 
directory subdirectory/file naming, organization of machine/platform code etc 
among other things. Other than Video a lot of other system registers and 
features which are common with the rest of Davinci SoCs which if treated 
together is a good thing, whereas OMAP3 can be modified and developed with 
those on the OMAP family (OMAP4 for ex).

 
   There are number of possible improvements that still should be made 
   to the OMAP 3 ISP driver so this way both of the driver would easily 
   get them. To mention some:
   
   - Multiple output pipeline
   - Switch to videobuf2
   - Switch to GENIRQ
  
  Sure. There is definitely a design element convergence, and overtime I 
  think some of these would get into the core v4l2 infrastructure.
 
 --
 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] V4L: sh_mobile_ceu_camera: fix Oops when USERPTR mapping fails

2011-07-04 Thread Guennadi Liakhovetski
If vb2_dma_contig_get_userptr() fails on a videobuffer, driver's
.buf_init() method will not be called and the list will not be
initialised. Trying to remove an uninitialised element from a list leads
to a NULL-dereference.

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

diff --git a/drivers/media/video/sh_mobile_ceu_camera.c 
b/drivers/media/video/sh_mobile_ceu_camera.c
index 3ae5c9c..a851a3e 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -421,8 +421,12 @@ static void sh_mobile_ceu_videobuf_release(struct 
vb2_buffer *vb)
pcdev-active = NULL;
}
 
-   /* Doesn't hurt also if the list is empty */
-   list_del_init(buf-queue);
+   /*
+* Doesn't hurt also if the list is empty, but it hurts, if queuing the
+* buffer failed, and .buf_init() hasn't been called
+*/
+   if (buf-queue.next)
+   list_del_init(buf-queue);
 
spin_unlock_irq(pcdev-lock);
 }
-- 
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


Re: [PATCH] V4L: sh_mobile_ceu_camera: fix Oops when USERPTR mapping fails

2011-07-04 Thread Bastian Hecht


On Mon, 4 Jul 2011, Guennadi Liakhovetski wrote:

 If vb2_dma_contig_get_userptr() fails on a videobuffer, driver's
 .buf_init() method will not be called and the list will not be
 initialised. Trying to remove an uninitialised element from a list leads
 to a NULL-dereference.
 
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de

Tested on mackerel.

Tested-by: Bastian Hecht hec...@gmail.com

Thanks,

 Bastian

 ---
  drivers/media/video/sh_mobile_ceu_camera.c |8 ++--
  1 files changed, 6 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/video/sh_mobile_ceu_camera.c 
 b/drivers/media/video/sh_mobile_ceu_camera.c
 index 3ae5c9c..a851a3e 100644
 --- a/drivers/media/video/sh_mobile_ceu_camera.c
 +++ b/drivers/media/video/sh_mobile_ceu_camera.c
 @@ -421,8 +421,12 @@ static void sh_mobile_ceu_videobuf_release(struct 
 vb2_buffer *vb)
   pcdev-active = NULL;
   }
  
 - /* Doesn't hurt also if the list is empty */
 - list_del_init(buf-queue);
 + /*
 +  * Doesn't hurt also if the list is empty, but it hurts, if queuing the
 +  * buffer failed, and .buf_init() hasn't been called
 +  */
 + if (buf-queue.next)
 + list_del_init(buf-queue);
  
   spin_unlock_irq(pcdev-lock);
  }
 -- 
 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


[RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset

2011-07-04 Thread Mauro Carvalho Chehab
Em 29-06-2011 09:51, Tomasz Stanislawski escreveu:
 The 1080p59_94 is supported by latest Samsung SoC.
 
 Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 Reviewed-by: Hans Verkuil hverk...@xs4all.nl
 ---
  drivers/media/video/v4l2-common.c |1 +
  include/linux/videodev2.h |1 +
  2 files changed, 2 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/media/video/v4l2-common.c 
 b/drivers/media/video/v4l2-common.c
 index 06b9f9f..003e648 100644
 --- a/drivers/media/video/v4l2-common.c
 +++ b/drivers/media/video/v4l2-common.c
 @@ -582,6 +582,7 @@ int v4l_fill_dv_preset_info(u32 preset, struct 
 v4l2_dv_enum_preset *info)
   { 1920, 1080, 1080p@30 }, /* V4L2_DV_1080P30 */
   { 1920, 1080, 1080p@50 }, /* V4L2_DV_1080P50 */
   { 1920, 1080, 1080p@60 }, /* V4L2_DV_1080P60 */
 + { 1920, 1080, 1080p@59.94 },  /* V4L2_DV_1080P59_94 */
   };
  
   if (info == NULL || preset = ARRAY_SIZE(dv_presets))
 diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
 index 8a4c309..7c77c4e 100644
 --- a/include/linux/videodev2.h
 +++ b/include/linux/videodev2.h
 @@ -872,6 +872,7 @@ struct v4l2_dv_enum_preset {
  #define  V4L2_DV_1080P30 16 /* SMPTE 296M */
  #define  V4L2_DV_1080P50 17 /* BT.1120 */
  #define  V4L2_DV_1080P60 18 /* BT.1120 */
 +#define  V4L2_DV_1080P59_94  19
  
  /*
   *   D V B T T I M I N G S

This patch deserves further discussions, as the specs that define the presets
are not so clear with respect to 60Hz and 60/1.001 Hz.

Let me summarize the issue.



1) PRESET STANDARDS
   == =

There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and CEA 
861.

At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as 60 Hz. 
BT.1120
follows the same logic, as it uses BT.709 as a reference for video timings.

The CEA-861-E spec says at item 4, that:

A video timing with a vertical frequency that is an integer multiple of 
6.00 Hz (i.e. 24.00, 30.00, 60.00,
120.00 or 240.00 Hz) is considered to be the same as a video timing 
with the equivalent detailed timing
information but where the vertical frequency is adjusted by a factor of 
1000/1001 (i.e., 24/1.001, 30/1.001,
60/1.001, 120/1.001 or 240/1.001). That is, they are considered two 
versions of the same video timing but
with slightly different pixel clock frequencies. Therefore, a DTV that 
declares it is capable of displaying a
video timing with a vertical frequency that is either an integer 
multiple of 6 Hz or an integer multiple of 6
Hz adjusted by a factor of 1000/1001 shall be capable of displaying 
both versions of the video timing.

At the same item, the table 2 describes several video parameters for each 
preset, associating the
Video Identification Codes (VIC) for each preset.

Table 4 associates each VIC with the supported formats. For example, VIC 16 
means a resolution of
1920x1080 at 59.94Hz/60Hz. The spec does explicitly allow that all vertical 
frequencies that are
multiple of 6 Hz to accept both 59.94 Hz and 60 Hz, as said at note 3 of table 
2:

3. A video timing with a vertical frequency that is an integer multiple 
of 6.00 Hz (i.e. 24.00, 30.00, 60.00, 120.00 or
240.00 Hz) is considered to be the same as a video timing with the 
equivalent detailed timing information but where
the vertical frequency is adjusted by a factor of 1000/1001 (i.e., 
24/1.001, 30/1.001, 60/1.001, 120/1.001 or
240/1.001). That is, they are considered two versions of the same video 
timing but with slightly different pixel clock
frequencies. The vertical frequencies of the 240p, 480p, and 480i video 
formats are typically adjusted by a factor of
exactly 1000/1001 for NTSC video compatibility, while the 576p, 576i, 
and the HDTV video formats are not. The
VESA DMT standard [65] specifies a ± 0.5% pixel clock frequency 
tolerance. Therefore, the nominally 25.175 MHz
pixel clock frequency value given for video identification code 1 may 
be adjusted to 25.2 MHz to obtain an exact 60
Hz vertical frequency.

In other words, the preset for 1920x1080p@60Hz can be used for both 60Hz and 
59.94 Hz,
according with the above note, being 59.94 Hz the typical value (e. g. the 
value that
should be used on most places).

However, there are some 60 Hz vertical resolutions that have VIC's with 
different framerates (like 59.94Hz, 60.054Hz, etc). Those seem to not be
covered by the multiple of 6.00 Hz rule.

2. V4L2 API
    ===

The V4L2 specs define a DV timing as having those fields:

__u32   width   Width of the active video in pixels
__u32   height  Height of the active video in lines
__u32   interlaced  Progressive (0) or interlaced (1)
__u32   polarities  This is a 

Re: [ RFC PATCH 0/8] RFC for Media Controller capture driver for DM365

2011-07-04 Thread Sakari Ailus
Hadli, Manjunath wrote:
 Thank you Laurent.

Hi Manjunath,

 On Mon, Jul 04, 2011 at 18:52:37, Laurent Pinchart wrote:
 Hi Manjunath,
 
 On Monday 04 July 2011 07:58:06 Hadli, Manjunath wrote:
 On Thu, Jun 30, 2011 at 19:27:36, Sakari Ailus wrote:
 
 [snip]
 
 I understand that not all the blocks are there. Are there any
 major functional differences between those in Davinci and those
 in OMAP 3? Could the OMAP 3 ISP driver made support Davinci ISP
 as well?
 
 Yes, there are a lot of major differences between OMAP3 and 
 Dm365/Dm355, both in terms of features, there IP, and the
 software interface, including all the registers which are
 entirely different. The closest omap3 would come to is only to
 DM6446. I do not think OMAP3 driver can be made to support Dm355
 and Dm365. It is good to keep the OMAP3 neat and clean to cater
 for OMAP4 and beyond, and keep the Davinci family separate. The
 names might look similar and hence confusing for you, but the
 names can as well be made the same as Dm365 blocks like ISIF and
 IPIPE and IPIPEIF which are different.
 
 The DM6446 ISP is very similar to the OMAP3 ISP, and thus quite
 different from the DM355/365 ISPs. Should the DM6446 be supported
 by the OMAP3 ISP driver, and the DM355/365 by this driver ?
 
 DM6446 capture IP is in some respects similar to OMAP3 for some
 features, but there are a large number of differences also (MMU,
 VRFB, a lot of display interfaces etc). Having a single driver
 catering to Since DM6446 and OMAP3 is going to be unwieldy. Also,
 DM6446 belongs to the Davinci family of chips, it should be clubbed
 with the other Davinci SoCs as it will simplify a lot of other things
 including directory subdirectory/file naming, organization of
 machine/platform code etc among other things. Other than Video a lot
 of other system registers and features which are common with the rest
 of Davinci SoCs which if treated together is a good thing, whereas
 OMAP3 can be modified and developed with those on the OMAP family
 (OMAP4 for ex).

Thanks for the clarifications.

What about the DM3730? As far as I understand, the ISP on that one is
supported by the OMAP 3 ISP driver. But it looks like that it's more
continuation for the OMAP family of the chips than the Davinci.

I glanced at the DM6446 documentation and at the register level the
interface looks somewhat different although some register names are the
same. I didn't found a proper TRM which would be as detailed as the OMAP
ones --- does TI have one available in public?

OMAP 4 has a quite different ISS --- which the ISP is a part of, and
which also is very different to the OMAP 3 one  --- so it's unlikely
that the same driver would support OMAP 3 and OMAP 4 ISPs.

Kind regards,

-- 
Sakari Ailus
sakari.ai...@iki.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: [PATCH 00/16] New drivers: DRX-K, TDA18271c2, Updates: CXD2099 and ngene

2011-07-04 Thread Hans von Marwijk
Hi

In which GIT or HG repository can I find these patches.

drivers/media/dvb/ngene/ngene-core.c  
...

Regards
Eckhard

 -Original Message-
 From: linux-media-ow...@vger.kernel.org 
 [mailto:linux-media-ow...@vger.kernel.org] On Behalf Of Oliver Endriss
 Sent: 03 July 2011 18:31
 To: linux-media@vger.kernel.org
 Cc: Mauro Carvalho Chehab
 Subject: [PATCH 00/16] New drivers: DRX-K, TDA18271c2, Updates: CXD2099 and 
 ngene
 
 [PATCH 01/16] tda18271c2dd: Initial check-in
 [PATCH 02/16] tda18271c2dd: Lots of coding-style fixes
 [PATCH 03/16] DRX-K: Initial check-in
 [PATCH 04/16] DRX-K: Shrink size of drxk_map.h
 [PATCH 05/16] DRX-K: Tons of coding-style fixes
 [PATCH 06/16] DRX-K, TDA18271c2: Add build support
 [PATCH 07/16] get_dvb_firmware: Get DRX-K firmware for Digital Devices DVB-CT 
 cards
 [PATCH 08/16] ngene: Support Digital Devices DuoFlex CT
 [PATCH 09/16] ngene: Coding style fixes
 [PATCH 10/16] ngene: Fix return code if no demux was found
 [PATCH 11/16] ngene: Fix name of Digital Devices PCIe/miniPCIe
 [PATCH 12/16] ngene: Support DuoFlex CT attached to CineS2 and SaTiX-S2
 [PATCH 13/16] cxd2099: Update to latest version
 [PATCH 14/16] cxd2099: Codingstyle fixes
 [PATCH 15/16] ngene: Update for latest cxd2099
 [PATCH 16/16] ngene: Strip dummy packets inserted by the driver
 
 --
 
 VDR Remote Plugin 0.4.0: http://www.escape-edv.de/endriss/vdr/
 4 MByte Mod: http://www.escape-edv.de/endriss/dvb-mem-mod/
 Full-TS Mod: http://www.escape-edv.de/endriss/dvb-full-ts-mod/
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
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 v3 04/19] s5p-fimc: Remove sclk_cam clock handling

2011-07-04 Thread Sylwester Nawrocki
The external sclk_cam clocks will be handled at the media device
driver level.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-core.c |   12 ++--
 drivers/media/video/s5p-fimc/fimc-core.h |3 +--
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index 36a8d63..fd6a308 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -30,7 +30,7 @@
 #include fimc-core.h
 
 static char *fimc_clocks[MAX_FIMC_CLOCKS] = {
-   sclk_fimc, fimc, sclk_cam
+   sclk_fimc, fimc
 };
 
 static struct fimc_fmt fimc_formats[] = {
@@ -1648,7 +1648,6 @@ static int fimc_probe(struct platform_device *pdev)
struct samsung_fimc_driverdata *drv_data;
struct s5p_platform_fimc *pdata;
int ret = 0;
-   int cap_input_index = -1;
 
dev_dbg(pdev-dev, %s():\n, __func__);
 
@@ -1701,14 +1700,6 @@ static int fimc_probe(struct platform_device *pdev)
goto err_req_region;
}
 
-   fimc-num_clocks = MAX_FIMC_CLOCKS - 1;
-
-   /* Check if a video capture node needs to be registered. */
-   if (pdata  pdata-num_clients  0) {
-   cap_input_index = 0;
-   fimc-num_clocks++;
-   }
-
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(pdev-dev, failed to get IRQ resource\n);
@@ -1717,6 +1708,7 @@ static int fimc_probe(struct platform_device *pdev)
}
fimc-irq = res-start;
 
+   fimc-num_clocks = MAX_FIMC_CLOCKS;
ret = fimc_clk_get(fimc);
if (ret)
goto err_regs_unmap;
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h 
b/drivers/media/video/s5p-fimc/fimc-core.h
index c088dac..f059216 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.h
+++ b/drivers/media/video/s5p-fimc/fimc-core.h
@@ -34,7 +34,7 @@
 
 /* Time to wait for next frame VSYNC interrupt while stopping operation. */
 #define FIMC_SHUTDOWN_TIMEOUT  ((100*HZ)/1000)
-#define MAX_FIMC_CLOCKS3
+#define MAX_FIMC_CLOCKS2
 #define MODULE_NAMEs5p-fimc
 #define FIMC_MAX_DEVS  4
 #define FIMC_MAX_OUT_BUFS  4
@@ -46,7 +46,6 @@
 enum {
CLK_BUS,
CLK_GATE,
-   CLK_CAM,
 };
 
 enum fimc_dev_flags {
-- 
1.7.5.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 v3 0/19] s5p-fimc driver conversion to media controller and control framework

2011-07-04 Thread Sylwester Nawrocki
Hello,

following is a third version of a patchset converting s5p-fimc driver 
to the media controller API and control framework.

Except fixing minor bugs in the sensor registration code, the first patch
adding power management support has been significantly reworked. 
There is no yet support for a per frame power gating, I'd like to add
it in 3.2 as it seem to require modfications of v4l-mem2mem framework.

I'd like to get this patchset in v3.1, unless there are any issues pointed out. 

The changeset can be pulled from (within a few hours from now, after the
repository synchronisation cron job runs):

http://git.infradead.org/users/kmpark/linux-2.6-samsung
branch: s5p-fimc-next

Changes since v2:
- reworked (runtime) power management;
- added pm_runtime_get_sync/pm_runtime_put around sensor registration
  code so the clock for sensors is enabled during host driver's probe();
- reworked try_crop operation handler to support multiple of the prescaler
  ratio relationship constraint for format at the sink pad;
- corrected fimc_md_unregister_entities() function


Below is an original cover letter of v2.

-
In this version the ioctl handlers for format setting at the video node and
the FIMC subdev has been reworked so they use common functions for capture
data format adjustment to the hardware capabilities. This prevent trouble
from any differences in handling ioctls at the subdev and the video node
when those are used simultaneously.

Except that I have killed a few bugs that jumped out when the driver was tried
to be used as a kernel module. 

Additionally to allow the driver to be used in V4L2 video node compatibility
mode (when sensor subdev is configured by the host driver rather that directly
by the applications through /dev/v4l-subdev*) a sysfs entry is added.
All that needs to be done to disable sensors configuration from /dev/video*
node level, in order to use sub-device user space API, is to write correct
string to s5p-fimc-md platform device subdev_conf_mode sysfs entry, e.g.

echo sub-dev  /sys/devices/platform/s5p-fimc-md/subdev_conf_mode
or to revert:
echo vid-dev  /sys/devices/platform/s5p-fimc-md/subdev_conf_mode

The following procedure is adopted for format and crop/composition
configuration at the FIMC.{n} (capture) subdevs:

1) set format at sink pad (this will reset sink crop rectangle)
2) set crop rectangle at sink pad (optional)
3) set rotate control (optional)
4) set crop (composition) at source pad (optional). Here scaling constraints
   are checked according to whether sink pad crop has been set or not and
   whether 90/270 deg rotation is set.
5) set format at source pad
6) set format at corresponding video node

Rotation can also be changed while streaming, in this case when 90/270 deg
rotation is attempted to be set and scaling bounds are exceeded 
(max. 64x downscaling) s_ctrl returns EINVAL.

I have tried this driver with v4l-compliance and it returned only 1 fail
on S/G_PRIORITY.

This patch set depends on my previous s5p-fimc bugfixes, available at: 
http://git.infradead.org/users/kmpark/linux-2.6-samsung/shortlog/refs/heads/s5p-fimc

as well as the control framework updates from Hans Verkuil:
http://www.spinics.net/lists/linux-media/msg33552.html
(patch 1...6, 8, 11).

Full source tree can be found at:
 http://git.infradead.org/users/kmpark/linux-2.6-samsung
 branch: s5p-fimc-next

I have skipped patch one patch in this series comparing to first version:
s5p-fimc: Add support for runtime PM in the mem-to-mem driver
This patch is available in the above git repository. 
I need to work a bit more on that one.

Comments and suggestions are welcome!
--


Thanks,
--
Sylwester Nawrocki
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


[PATCH v3 10/19] s5p-fimc: Conversion to the control framework

2011-07-04 Thread Sylwester Nawrocki
The FIMC entity supports rotation, horizontal and vertical flip
in camera capture and memory-to-memory operation mode.
Due to atomic contexts used in mem-to-mem driver the control
values need to be cached in drivers internal data structure.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   60 +++---
 drivers/media/video/s5p-fimc/fimc-core.c|  291 +++
 drivers/media/video/s5p-fimc/fimc-core.h|   34 ++--
 drivers/media/video/s5p-fimc/fimc-mdevice.c |   11 +-
 drivers/media/video/s5p-fimc/fimc-reg.c |   32 +---
 5 files changed, 186 insertions(+), 242 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index 0ceb16d..b193b7e 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -27,6 +27,7 @@
 #include media/videobuf2-core.h
 #include media/videobuf2-dma-contig.h
 
+#include fimc-mdevice.h
 #include fimc-core.h
 
 static int fimc_stop_capture(struct fimc_dev *fimc)
@@ -257,6 +258,29 @@ static struct vb2_ops fimc_capture_qops = {
.stop_streaming = stop_streaming,
 };
 
+/**
+ * fimc_capture_ctrls_create - initialize the control handler
+ *
+ * Initialize the capture video node control handler and populate it
+ * with FIMC specific controls. If the linked sensor subdevice does
+ * not expose a video node add its controls to the FIMC control
+ * handler. This function must be called with the graph mutex held.
+ */
+int fimc_capture_ctrls_create(struct fimc_dev *fimc)
+{
+   int ret;
+
+   if (WARN_ON(fimc-vid_cap.ctx == NULL))
+   return -ENXIO;
+   if (fimc-vid_cap.ctx-ctrls_rdy)
+   return 0;
+   ret = fimc_ctrls_create(fimc-vid_cap.ctx);
+   if (ret || subdev_has_devnode(fimc-pipeline.sensor))
+   return ret;
+   return v4l2_ctrl_add_handler(fimc-vid_cap.ctx-ctrl_handler,
+   fimc-pipeline.sensor-ctrl_handler);
+}
+
 static int fimc_capture_open(struct file *file)
 {
struct fimc_dev *fimc = video_drvdata(file);
@@ -277,9 +301,10 @@ static int fimc_capture_open(struct file *file)
return ret;
}
 
-   ++fimc-vid_cap.refcnt;
+   if (++fimc-vid_cap.refcnt == 1)
+   ret = fimc_capture_ctrls_create(fimc);
 
-   return 0;
+   return ret;
 }
 
 static int fimc_capture_close(struct file *file)
@@ -290,11 +315,11 @@ static int fimc_capture_close(struct file *file)
 
if (--fimc-vid_cap.refcnt == 0) {
fimc_stop_capture(fimc);
+   fimc_ctrls_delete(fimc-vid_cap.ctx);
vb2_queue_release(fimc-vid_cap.vbq);
}
 
pm_runtime_put_sync(fimc-pdev-dev);
-
return v4l2_fh_release(file);
 }
 
@@ -530,30 +555,6 @@ static int fimc_cap_dqbuf(struct file *file, void *priv,
return vb2_dqbuf(fimc-vid_cap.vbq, buf, file-f_flags  O_NONBLOCK);
 }
 
-static int fimc_cap_s_ctrl(struct file *file, void *priv,
-  struct v4l2_control *ctrl)
-{
-   struct fimc_dev *fimc = video_drvdata(file);
-   struct fimc_ctx *ctx = fimc-vid_cap.ctx;
-   int ret = -EINVAL;
-
-   /* Allow any controls but 90/270 rotation while streaming */
-   if (!fimc_capture_active(ctx-fimc_dev) ||
-   ctrl-id != V4L2_CID_ROTATE ||
-   (ctrl-value != 90  ctrl-value != 270)) {
-   ret = check_ctrl_val(ctx, ctrl);
-   if (!ret) {
-   ret = fimc_s_ctrl(ctx, ctrl);
-   if (!ret)
-   ctx-state |= FIMC_PARAMS;
-   }
-   }
-   if (ret == -EINVAL)
-   ret = v4l2_subdev_call(ctx-fimc_dev-vid_cap.sd,
-  core, s_ctrl, ctrl);
-   return ret;
-}
-
 static int fimc_cap_cropcap(struct file *file, void *fh,
struct v4l2_cropcap *cr)
 {
@@ -640,10 +641,6 @@ static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops 
= {
.vidioc_streamon= fimc_cap_streamon,
.vidioc_streamoff   = fimc_cap_streamoff,
 
-   .vidioc_queryctrl   = fimc_vidioc_queryctrl,
-   .vidioc_g_ctrl  = fimc_vidioc_g_ctrl,
-   .vidioc_s_ctrl  = fimc_cap_s_ctrl,
-
.vidioc_g_crop  = fimc_cap_g_crop,
.vidioc_s_crop  = fimc_cap_s_crop,
.vidioc_cropcap = fimc_cap_cropcap,
@@ -727,6 +724,7 @@ int fimc_register_capture_device(struct fimc_dev *fimc,
if (ret)
goto err_ent;
 
+   vfd-ctrl_handler = ctx-ctrl_handler;
ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
if (ret) {
v4l2_err(v4l2_dev, Failed to register video device\n);
diff --git 

[PATCH v3 13/19] s5p-fimc: Correct color format enumeration

2011-07-04 Thread Sylwester Nawrocki
Create separate VIDIOC_ENUM_FMT ioctl handlers for video capture
and mem-to-mem video node. This is needed as some formats are
valid only for the video capture and some only for the mem-to-mem
video node. Create single function for pixel format lookup out of
find_mbus_format() and find_format().

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   32 ++
 drivers/media/video/s5p-fimc/fimc-core.c|   61 +--
 drivers/media/video/s5p-fimc/fimc-core.h|5 +-
 drivers/media/video/s5p-fimc/fimc-mdevice.c |2 +-
 4 files changed, 55 insertions(+), 45 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index 7af4ac5..fb0d89a 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -376,6 +376,22 @@ static int fimc_vidioc_querycap_capture(struct file *file, 
void *priv,
return 0;
 }
 
+static int fimc_cap_enum_fmt_mplane(struct file *file, void *priv,
+   struct v4l2_fmtdesc *f)
+{
+   struct fimc_fmt *fmt;
+
+   fmt = fimc_find_format(NULL, NULL, FMT_FLAGS_CAM | FMT_FLAGS_M2M,
+  f-index);
+   if (!fmt)
+   return -EINVAL;
+   strncpy(f-description, fmt-name, sizeof(f-description) - 1);
+   f-pixelformat = fmt-fourcc;
+   if (fmt-fourcc == V4L2_MBUS_FMT_JPEG_1X8)
+   f-flags |= V4L2_FMT_FLAG_COMPRESSED;
+   return 0;
+}
+
 /* Synchronize formats of the camera interface input and attached  sensor. */
 static int sync_capture_fmt(struct fimc_ctx *ctx)
 {
@@ -394,7 +410,7 @@ static int sync_capture_fmt(struct fimc_ctx *ctx)
}
dbg(w: %d, h: %d, code= %d, fmt-width, fmt-height, fmt-code);
 
-   frame-fmt = find_mbus_format(fmt, FMT_FLAGS_CAM);
+   frame-fmt = fimc_find_format(NULL, fmt-code, FMT_FLAGS_CAM, -1);
if (!frame-fmt) {
err(fimc source format not found\n);
return -EINVAL;
@@ -456,12 +472,10 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void 
*priv,
frame = ctx-d_frame;
 
pix = f-fmt.pix_mp;
-   frame-fmt = find_format(f, FMT_FLAGS_M2M | FMT_FLAGS_CAM);
-   if (!frame-fmt) {
-   v4l2_err(fimc-vid_cap.vfd,
-Not supported capture (FIMC target) color format\n);
+   frame-fmt = fimc_find_format(pix-pixelformat, NULL,
+ FMT_FLAGS_M2M | FMT_FLAGS_CAM, 0);
+   if (WARN(frame-fmt == NULL, Pixel format lookup failed\n))
return -EINVAL;
-   }
 
for (i = 0; i  frame-fmt-colplanes; i++) {
frame-payload[i] =
@@ -641,7 +655,7 @@ static int fimc_cap_s_crop(struct file *file, void *fh, 
struct v4l2_crop *cr)
 static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = {
.vidioc_querycap= fimc_vidioc_querycap_capture,
 
-   .vidioc_enum_fmt_vid_cap_mplane = fimc_vidioc_enum_fmt_mplane,
+   .vidioc_enum_fmt_vid_cap_mplane = fimc_cap_enum_fmt_mplane,
.vidioc_try_fmt_vid_cap_mplane  = fimc_cap_try_fmt_mplane,
.vidioc_s_fmt_vid_cap_mplane= fimc_cap_s_fmt_mplane,
.vidioc_g_fmt_vid_cap_mplane= fimc_cap_g_fmt_mplane,
@@ -702,7 +716,6 @@ int fimc_register_capture_device(struct fimc_dev *fimc,
struct video_device *vfd;
struct fimc_vid_cap *vid_cap;
struct fimc_ctx *ctx;
-   struct v4l2_format f;
struct fimc_frame *fr;
struct vb2_queue *q;
int ret = -ENOMEM;
@@ -717,9 +730,8 @@ int fimc_register_capture_device(struct fimc_dev *fimc,
ctx-state   = FIMC_CTX_CAP;
 
/* Default format of the output frames */
-   f.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32;
fr = ctx-d_frame;
-   fr-fmt = find_format(f, FMT_FLAGS_M2M);
+   fr-fmt = fimc_find_format(NULL, NULL, FMT_FLAGS_CAM, 0);
fr-width = fr-f_width = fr-o_width = 640;
fr-height = fr-f_height = fr-o_height = 480;
 
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index a3edaf8..8bd8d30 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -866,18 +866,17 @@ static int fimc_m2m_querycap(struct file *file, void *fh,
return 0;
 }
 
-int fimc_vidioc_enum_fmt_mplane(struct file *file, void *priv,
-   struct v4l2_fmtdesc *f)
+static int fimc_m2m_enum_fmt_mplane(struct file *file, void *priv,
+   struct v4l2_fmtdesc *f)
 {
struct fimc_fmt *fmt;
 
-   if (f-index = ARRAY_SIZE(fimc_formats))
+   fmt = fimc_find_format(NULL, NULL, FMT_FLAGS_M2M, f-index);
+   if (!fmt)
return -EINVAL;
 
-   fmt = fimc_formats[f-index];
 

[PATCH v3 19/19] s5p-fimc: Add runtime PM support in the camera capture driver

2011-07-04 Thread Sylwester Nawrocki
Add support for whole pipeline suspend/resume. Sensors must support
suspend/resume through s_power subdev operation.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   77 ---
 drivers/media/video/s5p-fimc/fimc-core.c|   10 ++--
 drivers/media/video/s5p-fimc/fimc-core.h|1 +
 3 files changed, 64 insertions(+), 24 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index 3b64788..33776ff 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -73,7 +73,7 @@ static int fimc_start_capture(struct fimc_dev *fimc)
return ret;
 }
 
-static int fimc_stop_capture(struct fimc_dev *fimc)
+static int fimc_stop_capture(struct fimc_dev *fimc, bool suspend)
 {
struct fimc_vid_cap *cap = fimc-vid_cap;
struct fimc_vid_buffer *buf;
@@ -89,26 +89,28 @@ static int fimc_stop_capture(struct fimc_dev *fimc)
 
wait_event_timeout(fimc-irq_queue,
   !test_bit(ST_CAPT_SHUT, fimc-state),
-  FIMC_SHUTDOWN_TIMEOUT);
+  (2*HZ/10)); /* 200 ms */
 
spin_lock_irqsave(fimc-slock, flags);
-   fimc-state = ~(1  ST_CAPT_RUN | 1  ST_CAPT_PEND |
-1  ST_CAPT_SHUT | 1  ST_CAPT_STREAM |
-1  ST_CAPT_ISP_STREAM);
+   fimc-state = ~(1  ST_CAPT_RUN | 1  ST_CAPT_SHUT |
+1  ST_CAPT_STREAM | 1  ST_CAPT_ISP_STREAM);
+   if (!suspend)
+   fimc-state = ~(1  ST_CAPT_PEND | 1  ST_CAPT_SUSPENDED);
 
-   fimc-vid_cap.active_buf_cnt = 0;
-
-   /* Release buffers that were enqueued in the driver by videobuf2. */
-   while (!list_empty(cap-pending_buf_q)) {
+   /* Release unused buffers */
+   while (!suspend  !list_empty(cap-pending_buf_q)) {
buf = fimc_pending_queue_pop(cap);
vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
}
-
+   /* If suspending put unused buffers onto pending queue */
while (!list_empty(cap-active_buf_q)) {
buf = fimc_active_queue_pop(cap);
-   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   if (suspend)
+   fimc_pending_queue_add(cap, buf);
+   else
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
}
-
+   set_bit(ST_CAPT_SUSPENDED, fimc-state);
spin_unlock_irqrestore(fimc-slock, flags);
dbg(state: 0x%lx, fimc-state);
 
@@ -117,11 +119,39 @@ static int fimc_stop_capture(struct fimc_dev *fimc)
 
 int fimc_capture_suspend(struct fimc_dev *fimc)
 {
-   return -EBUSY;
+   bool suspend = fimc_capture_in_use(fimc);
+
+   int ret = fimc_stop_capture(fimc, suspend);
+   if (ret)
+   return ret;
+   return fimc_pipeline_shutdown(fimc);
 }
 
+static void buffer_queue(struct vb2_buffer *vb);
+
 int fimc_capture_resume(struct fimc_dev *fimc)
 {
+   struct fimc_vid_cap *vid_cap = fimc-vid_cap;
+   struct fimc_vid_buffer *buf;
+   int i;
+
+   if (!test_and_clear_bit(ST_CAPT_SUSPENDED, fimc-state))
+   return 0;
+
+   INIT_LIST_HEAD(fimc-vid_cap.active_buf_q);
+   vid_cap-buf_index = 0;
+   fimc_pipeline_initialize(fimc, fimc-vid_cap.vfd-entity,
+false);
+   fimc_start_capture(fimc);
+
+   clear_bit(ST_CAPT_SUSPENDED, fimc-state);
+
+   for (i = 0; i  vid_cap-reqbufs_count; i++) {
+   if (list_empty(vid_cap-pending_buf_q))
+   break;
+   buf = fimc_pending_queue_pop(vid_cap);
+   buffer_queue(buf-vb);
+   }
return 0;
 }
 
@@ -181,7 +211,7 @@ static int stop_streaming(struct vb2_queue *q)
if (!fimc_capture_active(fimc))
return -EINVAL;
 
-   return fimc_stop_capture(fimc);
+   return fimc_stop_capture(fimc, false);
 }
 
 static unsigned int get_plane_size(struct fimc_frame *fr, unsigned int plane)
@@ -248,8 +278,9 @@ static void buffer_queue(struct vb2_buffer *vb)
spin_lock_irqsave(fimc-slock, flags);
fimc_prepare_addr(ctx, buf-vb, ctx-d_frame, buf-paddr);
 
-   if (!test_bit(ST_CAPT_STREAM, fimc-state)
- vid_cap-active_buf_cnt  FIMC_MAX_OUT_BUFS) {
+   if (!test_bit(ST_CAPT_SUSPENDED, fimc-state) 
+   !test_bit(ST_CAPT_STREAM, fimc-state) 
+   vid_cap-active_buf_cnt  FIMC_MAX_OUT_BUFS) {
/* Setup the buffer directly for processing. */
int buf_id = (vid_cap-reqbufs_count == 1) ? -1 :
vid_cap-buf_index;
@@ -337,6 +368,7 @@ static int fimc_capture_open(struct file *file)
if (fimc_m2m_active(fimc))
return -EBUSY;
 
+   set_bit(ST_CAPT_INUSE, 

[PATCH v3 17/19] s5p-fimc: Add v4l2_device notification support for single frame capture

2011-07-04 Thread Sylwester Nawrocki
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   47 +++
 drivers/media/video/s5p-fimc/fimc-core.h|2 +
 drivers/media/video/s5p-fimc/fimc-mdevice.c |1 +
 include/media/s5p_fimc.h|9 +
 4 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index 2bfc050..c9420db 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -1029,6 +1029,53 @@ static const struct media_entity_operations 
fimc_media_ops = {
.link_setup = fimc_link_setup,
 };
 
+/**
+ * fimc_sensor_notify - v4l2_device notification from a sensor subdev
+ * @sd: pointer to a subdev generating the notification
+ * @notification: the notification type, must be S5P_FIMC_TX_END_NOTIFY
+ * @arg: pointer to an u32 type integer that stores the frame payload value
+ *
+ * The End Of Frame notification sent by sensor subdev in its still capture
+ * mode. If there is only a single VSYNC generated by the sensor at the
+ * beginning of a frame transmission, FIMC does not issue the LastIrq
+ * (end of frame) interrupt. And this notification is used to complete the
+ * frame capture and returning a buffer to user-space. Subdev drivers should
+ * call this notification from their last 'End of frame capture' interrupt.
+ */
+void fimc_sensor_notify(struct v4l2_subdev *sd, unsigned int notification,
+   void *arg)
+{
+   struct fimc_sensor_info *sensor;
+   struct fimc_vid_buffer *buf;
+   struct fimc_md *fmd;
+   struct fimc_dev *fimc;
+   unsigned long flags;
+
+   if (sd == NULL)
+   return;
+
+   sensor = v4l2_get_subdev_hostdata(sd);
+   fmd = entity_to_fimc_mdev(sd-entity);
+
+   spin_lock_irqsave(fmd-slock, flags);
+   fimc = sensor ? sensor-host : NULL;
+
+   if (fimc  arg  notification == S5P_FIMC_TX_END_NOTIFY 
+   test_bit(ST_CAPT_PEND, fimc-state)) {
+   unsigned long irq_flags;
+   spin_lock_irqsave(fimc-slock, irq_flags);
+   if (!list_empty(fimc-vid_cap.active_buf_q)) {
+   buf = list_entry(fimc-vid_cap.active_buf_q.next,
+struct fimc_vid_buffer, list);
+   vb2_set_plane_payload(buf-vb, 0, *((u32 *)arg));
+   }
+   fimc_capture_irq_handler(fimc, true);
+   fimc_deactivate_capture(fimc);
+   spin_unlock_irqrestore(fimc-slock, irq_flags);
+   }
+   spin_unlock_irqrestore(fmd-slock, flags);
+}
+
 static int fimc_subdev_enum_mbus_code(struct v4l2_subdev *sd,
  struct v4l2_subdev_fh *fh,
  struct v4l2_subdev_mbus_code_enum *code)
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h 
b/drivers/media/video/s5p-fimc/fimc-core.h
index a0d13e4..3759250 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.h
+++ b/drivers/media/video/s5p-fimc/fimc-core.h
@@ -724,6 +724,8 @@ void fimc_unregister_capture_device(struct fimc_dev *fimc);
 int fimc_capture_ctrls_create(struct fimc_dev *fimc);
 int fimc_vid_cap_buf_queue(struct fimc_dev *fimc,
 struct fimc_vid_buffer *fimc_vb);
+void fimc_sensor_notify(struct v4l2_subdev *sd, unsigned int notification,
+   void *arg);
 int fimc_capture_suspend(struct fimc_dev *fimc);
 int fimc_capture_resume(struct fimc_dev *fimc);
 int fimc_capture_config_update(struct fimc_ctx *ctx);
diff --git a/drivers/media/video/s5p-fimc/fimc-mdevice.c 
b/drivers/media/video/s5p-fimc/fimc-mdevice.c
index d425b65..a050f91 100644
--- a/drivers/media/video/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/video/s5p-fimc/fimc-mdevice.c
@@ -738,6 +738,7 @@ static int __devinit fimc_md_probe(struct platform_device 
*pdev)
 
v4l2_dev = fmd-v4l2_dev;
v4l2_dev-mdev = fmd-media_dev;
+   v4l2_dev-notify = fimc_sensor_notify;
snprintf(v4l2_dev-name, sizeof(v4l2_dev-name), %s,
 dev_name(pdev-dev));
 
diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h
index 086a7aa..2b58904 100644
--- a/include/media/s5p_fimc.h
+++ b/include/media/s5p_fimc.h
@@ -60,4 +60,13 @@ struct s5p_platform_fimc {
struct s5p_fimc_isp_info *isp_info;
int num_clients;
 };
+
+/*
+ * v4l2_device notification id. This is only for internal use in the kernel.
+ * Sensor subdevs should issue S5P_FIMC_TX_END_NOTIFY notification in single
+ * frame capture mode when there is only one VSYNC pulse issued by the sensor
+ * at begining of the frame transmission.
+ */
+#define S5P_FIMC_TX_END_NOTIFY _IO('e', 0)
+
 #endif /* S5P_FIMC_H_ */
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body 

[PATCH v3 15/19] s5p-fimc: Add subdev for the FIMC processing block

2011-07-04 Thread Sylwester Nawrocki
This subdev interface exposes the internal scaler and color converter
functionality to user space. Resolution and media bus format can now
be configured explicitly by applications. Camera frame composition
onto the output buffer can be configured through set/get_crop at FIMC.{n}
source pad. Additionally crop, controls and composition may be
reconfigured while streaming.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |  688 ---
 drivers/media/video/s5p-fimc/fimc-core.c|   32 +-
 drivers/media/video/s5p-fimc/fimc-core.h|   51 ++-
 drivers/media/video/s5p-fimc/fimc-mdevice.c |   37 ++-
 4 files changed, 709 insertions(+), 99 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index ecb0246..4d7b279 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -67,6 +67,7 @@ static int fimc_start_capture(struct fimc_dev *fimc)
fimc_hw_set_effect(ctx);
fimc_hw_set_output_path(ctx);
fimc_hw_set_out_dma(ctx);
+   clear_bit(ST_CAPT_APPLY_CFG, fimc-state);
}
spin_unlock_irqrestore(fimc-slock, flags);
return ret;
@@ -124,6 +125,33 @@ int fimc_capture_resume(struct fimc_dev *fimc)
return 0;
 }
 
+/**
+ * fimc_capture_config_update - apply the camera interface configuration
+ *
+ * To be called from within the interrupt handler with fimc.slock
+ * spinlock held. Camera pixel crop, rotation and image flip state will
+ * be updated in the H/W.
+ */
+int fimc_capture_config_update(struct fimc_ctx *ctx)
+{
+   struct fimc_dev *fimc = ctx-fimc_dev;
+   int ret;
+
+   spin_lock(ctx-slock);
+   fimc_hw_set_camera_offset(fimc, ctx-s_frame);
+   ret = fimc_set_scaler_info(ctx);
+   if (ret == 0) {
+   fimc_hw_set_prescaler(ctx);
+   fimc_hw_set_mainscaler(ctx);
+   fimc_hw_set_target_format(ctx);
+   fimc_hw_set_rotation(ctx);
+   fimc_prepare_dma_offset(ctx, ctx-d_frame);
+   fimc_hw_set_out_dma(ctx);
+   }
+   spin_unlock(ctx-slock);
+   return ret;
+}
+
 static int start_streaming(struct vb2_queue *q)
 {
struct fimc_ctx *ctx = q-drv_priv;
@@ -289,7 +317,7 @@ int fimc_capture_ctrls_create(struct fimc_dev *fimc)
if (fimc-vid_cap.ctx-ctrls_rdy)
return 0;
ret = fimc_ctrls_create(fimc-vid_cap.ctx);
-   if (ret || subdev_has_devnode(fimc-pipeline.sensor))
+   if (ret || !fimc-vid_cap.vid_dev_compat)
return ret;
return v4l2_ctrl_add_handler(fimc-vid_cap.ctx-ctrl_handler,
fimc-pipeline.sensor-ctrl_handler);
@@ -358,7 +386,6 @@ static int fimc_capture_mmap(struct file *file, struct 
vm_area_struct *vma)
return vb2_mmap(fimc-vid_cap.vbq, vma);
 }
 
-/* video device file operations */
 static const struct v4l2_file_operations fimc_capture_fops = {
.owner  = THIS_MODULE,
.open   = fimc_capture_open,
@@ -368,6 +395,143 @@ static const struct v4l2_file_operations 
fimc_capture_fops = {
.mmap   = fimc_capture_mmap,
 };
 
+/*
+ * Format and crop negotiation helpers
+ */
+
+static struct fimc_fmt *fimc_capture_try_format(struct fimc_ctx *ctx,
+   u32 *width, u32 *height,
+   u32 *code, u32 *fourcc, int pad)
+{
+   bool rotation = ctx-rotation == 90 || ctx-rotation == 270;
+   struct fimc_dev *fimc = ctx-fimc_dev;
+   struct samsung_fimc_variant *var = fimc-variant;
+   struct fimc_pix_limit *pl = var-pix_limit;
+   struct fimc_frame *dst = ctx-d_frame;
+   u32 depth, min_w, max_w, min_h, align_h = 4;
+   u32 mask = FMT_FLAGS_CAM;
+   struct fimc_fmt *ffmt;
+
+   /* Color conversion from/to JPEG is not supported */
+   if (pad == FIMC_SD_PAD_SOURCE 
+   fimc_fmt_is_jpeg(ctx-s_frame.fmt-color))
+   *code = V4L2_MBUS_FMT_JPEG_1X8;
+   if (fourcc)
+   mask |= FMT_FLAGS_M2M;
+   ffmt = fimc_find_format(fourcc, code, mask, 0);
+   if (WARN_ON(!ffmt))
+   return NULL;
+   if (code)
+   *code = ffmt-mbus_code;
+   if (fourcc)
+   *fourcc = ffmt-fourcc;
+
+   if (pad == FIMC_SD_PAD_SINK) {
+   max_w = fimc_fmt_is_jpeg(ffmt-color) ?
+   pl-scaler_dis_w : pl-scaler_en_w;
+   /* Apply the camera input interface pixel constraints */
+   v4l_bound_align_image(width, 32, max_w, 4,
+ height, 32, FIMC_CAMIF_MAX_HEIGHT, 1,
+ 0);
+   return ffmt;
+   }
+   /* Can't scale or crop in 

[PATCH v3 16/19] s5p-fimc: Add support for camera capture in JPEG format

2011-07-04 Thread Sylwester Nawrocki
Add support for transparent DMA transfer of JPEG data with MIPI-CSI2
USER1 format. In JPEG mode the color effect, scaling and cropping
is not supported. Same applies to image rotation and flip thus those
controls are marked as inactive when V4L2_PIX_FMT_JPEG pixelformat
is selected.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   17 ++-
 drivers/media/video/s5p-fimc/fimc-core.c|   70 ++-
 drivers/media/video/s5p-fimc/fimc-core.h|7 ++-
 drivers/media/video/s5p-fimc/fimc-reg.c |   31 
 drivers/media/video/s5p-fimc/regs-fimc.h|8 +--
 5 files changed, 81 insertions(+), 52 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index 4d7b279..2bfc050 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -64,7 +64,7 @@ static int fimc_start_capture(struct fimc_dev *fimc)
fimc_hw_set_mainscaler(ctx);
fimc_hw_set_target_format(ctx);
fimc_hw_set_rotation(ctx);
-   fimc_hw_set_effect(ctx);
+   fimc_hw_set_effect(ctx, false);
fimc_hw_set_output_path(ctx);
fimc_hw_set_out_dma(ctx);
clear_bit(ST_CAPT_APPLY_CFG, fimc-state);
@@ -696,6 +696,16 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void 
*fh,
return 0;
 }
 
+static void fimc_capture_mark_jpeg_xfer(struct fimc_ctx *ctx, bool jpeg)
+{
+   ctx-scaler.enabled = !jpeg;
+   fimc_ctrls_activate(ctx, !jpeg);
+
+   if (jpeg)
+   set_bit(ST_CAPT_JPEG, ctx-fimc_dev-state);
+   else
+   clear_bit(ST_CAPT_JPEG, ctx-fimc_dev-state);
+}
 
 static int fimc_cap_s_fmt_mplane(struct file *file, void *priv,
 struct v4l2_format *f)
@@ -751,6 +761,9 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void 
*priv,
if (fimc-vid_cap.vid_dev_compat)
set_frame_crop(ff, 0, 0, mf-width, mf-height);
 
+   /* Switch to the transparent DMA transfer mode if required */
+   fimc_capture_mark_jpeg_xfer(ctx, fimc_fmt_is_jpeg(ff-fmt-color));
+
return ret;
 }
 
@@ -1086,6 +1099,8 @@ static int fimc_subdev_set_fmt(struct v4l2_subdev *sd,
*mf = fmt-format;
return 0;
}
+   fimc_capture_mark_jpeg_xfer(ctx, fimc_fmt_is_jpeg(ffmt-color));
+
ff = fmt-pad == FIMC_SD_PAD_SINK ?
ctx-s_frame : ctx-d_frame;
 
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index 4b9f471..9538ab7 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -159,22 +159,28 @@ static struct fimc_fmt fimc_formats[] = {
.memplanes  = 2,
.colplanes  = 2,
.flags  = FMT_FLAGS_M2M,
+   }, {
+   .name   = JPEG encoded data,
+   .fourcc = V4L2_PIX_FMT_JPEG,
+   .color  = S5P_FIMC_JPEG,
+   .depth  = { 8 },
+   .memplanes  = 1,
+   .colplanes  = 1,
+   .mbus_code  = V4L2_MBUS_FMT_JPEG_1X8,
+   .flags  = FMT_FLAGS_CAM,
},
 };
 
-int fimc_check_scaler_ratio(int sw, int sh, int dw, int dh, int rot)
+int fimc_check_scaler_ratio(struct fimc_ctx *ctx, int sw, int sh,
+   int dw, int dh, int rotation)
 {
-   int tx, ty;
+   if (rotation == 90 || rotation == 270)
+   swap(dw, dh);
 
-   if (rot == 90 || rot == 270) {
-   ty = dw;
-   tx = dh;
-   } else {
-   tx = dw;
-   ty = dh;
-   }
+   if (!ctx-scaler.enabled)
+   return (sw == dw  sh == dh) ? 0 : -EINVAL;
 
-   if ((sw = SCALER_MAX_HRATIO * tx) || (sh = SCALER_MAX_VRATIO * ty))
+   if ((sw = SCALER_MAX_HRATIO * dw) || (sh = SCALER_MAX_VRATIO * dh))
return -EINVAL;
 
return 0;
@@ -321,7 +327,7 @@ static int stop_streaming(struct vb2_queue *q)
return 0;
 }
 
-void fimc_capture_irq_handler(struct fimc_dev *fimc)
+void fimc_capture_irq_handler(struct fimc_dev *fimc, bool rel_buf)
 {
struct fimc_vid_cap *cap = fimc-vid_cap;
struct fimc_vid_buffer *v_buf;
@@ -329,7 +335,7 @@ void fimc_capture_irq_handler(struct fimc_dev *fimc)
struct timespec ts;
 
if (!list_empty(cap-active_buf_q) 
-   test_bit(ST_CAPT_RUN, fimc-state)) {
+   test_bit(ST_CAPT_RUN, fimc-state)  rel_buf) {
ktime_get_real_ts(ts);
 
v_buf = active_queue_pop(cap);
@@ -364,7 +370,8 @@ void fimc_capture_irq_handler(struct fimc_dev *fimc)
}
 
if (cap-active_buf_cnt 

[PATCH v3 12/19] s5p-fimc: Add PM helper function for streaming control

2011-07-04 Thread Sylwester Nawrocki
Create a helper function for (re)starting streaming in PM resume calls.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   80 ---
 drivers/media/video/s5p-fimc/fimc-core.c|4 +-
 drivers/media/video/s5p-fimc/fimc-core.h|3 +
 3 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index 7c6c420..7af4ac5 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -30,6 +30,48 @@
 #include fimc-mdevice.h
 #include fimc-core.h
 
+/**
+ * fimc_start_capture - initialize the H/W for camera capture operation
+ *
+ * Initialize the camera capture datapath so when this function successfuly
+ * completes all what is needed to start the capture pipeline is asserting
+ * the global capture bit ImgCptEn.
+ */
+static int fimc_start_capture(struct fimc_dev *fimc)
+{
+   struct fimc_ctx *ctx = fimc-vid_cap.ctx;
+   struct fimc_sensor_info *sensor;
+   unsigned long flags;
+   int ret = 0;
+
+   if (fimc-pipeline.sensor == NULL || ctx == NULL)
+   return -EIO;
+   sensor = v4l2_get_subdev_hostdata(fimc-pipeline.sensor);
+
+   spin_lock_irqsave(fimc-slock, flags);
+   fimc_prepare_dma_offset(ctx, ctx-d_frame);
+   fimc_set_yuv_order(ctx);
+
+   fimc_hw_set_camera_polarity(fimc, sensor-pdata);
+   fimc_hw_set_camera_type(fimc, sensor-pdata);
+   fimc_hw_set_camera_source(fimc, sensor-pdata);
+   fimc_hw_set_camera_offset(fimc, ctx-s_frame);
+
+   ret = fimc_set_scaler_info(ctx);
+   if (!ret) {
+   fimc_hw_set_input_path(ctx);
+   fimc_hw_set_prescaler(ctx);
+   fimc_hw_set_mainscaler(ctx);
+   fimc_hw_set_target_format(ctx);
+   fimc_hw_set_rotation(ctx);
+   fimc_hw_set_effect(ctx);
+   fimc_hw_set_output_path(ctx);
+   fimc_hw_set_out_dma(ctx);
+   }
+   spin_unlock_irqrestore(fimc-slock, flags);
+   return ret;
+}
+
 static int fimc_stop_capture(struct fimc_dev *fimc)
 {
unsigned long flags;
@@ -89,47 +131,19 @@ static int start_streaming(struct vb2_queue *q)
 {
struct fimc_ctx *ctx = q-drv_priv;
struct fimc_dev *fimc = ctx-fimc_dev;
-   struct s5p_fimc_isp_info *isp_info;
+   struct fimc_vid_cap *vid_cap = fimc-vid_cap;
int ret;
 
fimc_hw_reset(fimc);
 
-   ret = v4l2_subdev_call(fimc-vid_cap.sd, video, s_stream, 1);
-   if (ret  ret != -ENOIOCTLCMD)
-   return ret;
+   vid_cap-active_buf_cnt = 0;
+   vid_cap-frame_count = 0;
+   vid_cap-buf_index = 0;
 
-   ret = fimc_prepare_config(ctx, ctx-state);
+   ret = fimc_start_capture(fimc);
if (ret)
return ret;
 
-   isp_info = fimc-pdata-isp_info[fimc-vid_cap.input_index];
-   fimc_hw_set_camera_type(fimc, isp_info);
-   fimc_hw_set_camera_source(fimc, isp_info);
-   fimc_hw_set_camera_offset(fimc, ctx-s_frame);
-
-   if (ctx-state  FIMC_PARAMS) {
-   ret = fimc_set_scaler_info(ctx);
-   if (ret) {
-   err(Scaler setup error);
-   return ret;
-   }
-   fimc_hw_set_input_path(ctx);
-   fimc_hw_set_prescaler(ctx);
-   fimc_hw_set_mainscaler(ctx);
-   fimc_hw_set_target_format(ctx);
-   fimc_hw_set_rotation(ctx);
-   fimc_hw_set_effect(ctx);
-   }
-
-   fimc_hw_set_output_path(ctx);
-   fimc_hw_set_out_dma(ctx);
-
-   INIT_LIST_HEAD(fimc-vid_cap.pending_buf_q);
-   INIT_LIST_HEAD(fimc-vid_cap.active_buf_q);
-   fimc-vid_cap.active_buf_cnt = 0;
-   fimc-vid_cap.frame_count = 0;
-   fimc-vid_cap.buf_index = 0;
-
set_bit(ST_CAPT_PEND, fimc-state);
return 0;
 }
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index cb89146..a3edaf8 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -476,7 +476,7 @@ int fimc_prepare_addr(struct fimc_ctx *ctx, struct 
vb2_buffer *vb,
 }
 
 /* Set order for 1 and 2 plane YCBCR 4:2:2 formats. */
-static void fimc_set_yuv_order(struct fimc_ctx *ctx)
+void fimc_set_yuv_order(struct fimc_ctx *ctx)
 {
/* The one only mode supported in SoC. */
ctx-in_order_2p = S5P_FIMC_LSB_CRCB;
@@ -518,7 +518,7 @@ static void fimc_set_yuv_order(struct fimc_ctx *ctx)
dbg(ctx-out_order_1p= %d, ctx-out_order_1p);
 }
 
-static void fimc_prepare_dma_offset(struct fimc_ctx *ctx, struct fimc_frame *f)
+void fimc_prepare_dma_offset(struct fimc_ctx *ctx, struct fimc_frame *f)
 {
struct samsung_fimc_variant *variant = ctx-fimc_dev-variant;
u32 

[PATCH v3 18/19] s5p-fimc: Use consistent names for the buffer list functions

2011-07-04 Thread Sylwester Nawrocki
Also correct and improve *_queue_add/pop functions description.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |6 ++--
 drivers/media/video/s5p-fimc/fimc-core.c|6 ++--
 drivers/media/video/s5p-fimc/fimc-core.h|   38 +-
 3 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index c9420db..3b64788 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -100,12 +100,12 @@ static int fimc_stop_capture(struct fimc_dev *fimc)
 
/* Release buffers that were enqueued in the driver by videobuf2. */
while (!list_empty(cap-pending_buf_q)) {
-   buf = pending_queue_pop(cap);
+   buf = fimc_pending_queue_pop(cap);
vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
}
 
while (!list_empty(cap-active_buf_q)) {
-   buf = active_queue_pop(cap);
+   buf = fimc_active_queue_pop(cap);
vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
}
 
@@ -256,7 +256,7 @@ static void buffer_queue(struct vb2_buffer *vb)
 
fimc_hw_set_output_addr(fimc, buf-paddr, buf_id);
buf-index = vid_cap-buf_index;
-   active_queue_add(vid_cap, buf);
+   fimc_active_queue_add(vid_cap, buf);
 
if (++vid_cap-buf_index = FIMC_MAX_OUT_BUFS)
vid_cap-buf_index = 0;
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index 9538ab7..66d1af5 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -338,7 +338,7 @@ void fimc_capture_irq_handler(struct fimc_dev *fimc, bool 
rel_buf)
test_bit(ST_CAPT_RUN, fimc-state)  rel_buf) {
ktime_get_real_ts(ts);
 
-   v_buf = active_queue_pop(cap);
+   v_buf = fimc_active_queue_pop(cap);
 
tv = v_buf-vb.v4l2_buf.timestamp;
tv-tv_sec = ts.tv_sec;
@@ -355,12 +355,12 @@ void fimc_capture_irq_handler(struct fimc_dev *fimc, bool 
rel_buf)
 
if (!list_empty(cap-pending_buf_q)) {
 
-   v_buf = pending_queue_pop(cap);
+   v_buf = fimc_pending_queue_pop(cap);
fimc_hw_set_output_addr(fimc, v_buf-paddr, cap-buf_index);
v_buf-index = cap-buf_index;
 
/* Move the buffer to the capture active queue */
-   active_queue_add(cap, v_buf);
+   fimc_active_queue_add(cap, v_buf);
 
dbg(next frame: %d, done frame: %d,
fimc_hw_get_frame_index(fimc), v_buf-index);
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h 
b/drivers/media/video/s5p-fimc/fimc-core.h
index 3759250..879d5dd 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.h
+++ b/drivers/media/video/s5p-fimc/fimc-core.h
@@ -746,22 +746,27 @@ static inline void fimc_deactivate_capture(struct 
fimc_dev *fimc)
 }
 
 /*
- * Add buf to the capture active buffers queue.
- * Locking: Need to be called with fimc_dev::slock held.
+ * Buffer list manipulation functions. Must be called with fimc.slock held.
  */
-static inline void active_queue_add(struct fimc_vid_cap *vid_cap,
-   struct fimc_vid_buffer *buf)
+
+/**
+ * fimc_active_queue_add - add buffer to the capture active buffers queue
+ * @buf: buffer to add to the active buffers list
+ */
+static inline void fimc_active_queue_add(struct fimc_vid_cap *vid_cap,
+struct fimc_vid_buffer *buf)
 {
list_add_tail(buf-list, vid_cap-active_buf_q);
vid_cap-active_buf_cnt++;
 }
 
-/*
- * Pop a video buffer from the capture active buffers queue
- * Locking: Need to be called with fimc_dev::slock held.
+/**
+ * fimc_active_queue_pop - pop buffer from the capture active buffers queue
+ *
+ * The caller must assure the active_buf_q list is not empty.
  */
-static inline struct fimc_vid_buffer *
-active_queue_pop(struct fimc_vid_cap *vid_cap)
+static inline struct fimc_vid_buffer *fimc_active_queue_pop(
+   struct fimc_vid_cap *vid_cap)
 {
struct fimc_vid_buffer *buf;
buf = list_entry(vid_cap-active_buf_q.next,
@@ -771,16 +776,23 @@ active_queue_pop(struct fimc_vid_cap *vid_cap)
return buf;
 }
 
-/* Add video buffer to the capture pending buffers queue */
+/**
+ * fimc_pending_queue_add - add buffer to the capture pending buffers queue
+ * @buf: buffer to add to the pending buffers list
+ */
 static inline void fimc_pending_queue_add(struct fimc_vid_cap *vid_cap,
  struct fimc_vid_buffer *buf)
 {
list_add_tail(buf-list, vid_cap-pending_buf_q);
 }
 
-/* 

[PATCH v3 03/19] s5p-fimc: Remove registration of video nodes from probe()

2011-07-04 Thread Sylwester Nawrocki
Do not register video nodes during FIMC device probe. Also make
fimc_register_m2m_device() public for use by the media device driver.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |1 +
 drivers/media/video/s5p-fimc/fimc-core.c|   30 +++---
 drivers/media/video/s5p-fimc/fimc-core.h|1 +
 3 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index c9be15c..a806e48 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -922,4 +922,5 @@ void fimc_unregister_capture_device(struct fimc_dev *fimc)
video_unregister_device(vfd);
}
kfree(fimc-vid_cap.ctx);
+   fimc-vid_cap.ctx = NULL;
 }
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index c97494d..36a8d63 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -1494,7 +1494,7 @@ static struct v4l2_m2m_ops m2m_ops = {
.job_abort  = fimc_job_abort,
 };
 
-static int fimc_register_m2m_device(struct fimc_dev *fimc)
+int fimc_register_m2m_device(struct fimc_dev *fimc)
 {
struct video_device *vfd;
struct platform_device *pdev;
@@ -1568,13 +1568,16 @@ err_m2m_r1:
 
 void fimc_unregister_m2m_device(struct fimc_dev *fimc)
 {
-   if (fimc == NULL)
+   if (!fimc)
return;
 
-   v4l2_m2m_release(fimc-m2m.m2m_dev);
+   if (fimc-m2m.m2m_dev)
+   v4l2_m2m_release(fimc-m2m.m2m_dev);
v4l2_device_unregister(fimc-m2m.v4l2_dev);
-   media_entity_cleanup(fimc-m2m.vfd-entity);
-   video_unregister_device(fimc-m2m.vfd);
+   if (fimc-m2m.vfd) {
+   media_entity_cleanup(fimc-m2m.vfd-entity);
+   video_unregister_device(fimc-m2m.vfd);
+   }
 }
 
 static void fimc_clk_put(struct fimc_dev *fimc)
@@ -1739,25 +1742,12 @@ static int fimc_probe(struct platform_device *pdev)
goto err_irq;
}
 
-   ret = fimc_register_m2m_device(fimc);
-   if (ret)
-   goto err_irq;
-
-   /* At least one camera sensor is required to register capture node */
-   if (cap_input_index = 0) {
-   ret = fimc_register_capture_device(fimc);
-   if (ret)
-   goto err_m2m;
-   }
-
dev_dbg(pdev-dev, %s(): fimc-%d registered successfully\n,
__func__, fimc-id);
 
pm_runtime_put(fimc-pdev-dev);
return 0;
 
-err_m2m:
-   fimc_unregister_m2m_device(fimc);
 err_irq:
free_irq(fimc-irq, fimc);
 err_clk:
@@ -1769,7 +1759,6 @@ err_req_region:
kfree(fimc-regs_res);
 err_info:
kfree(fimc);
-
return ret;
 }
 
@@ -1858,9 +1847,6 @@ static int __devexit fimc_remove(struct platform_device 
*pdev)
fimc_runtime_suspend(pdev-dev);
pm_runtime_set_suspended(pdev-dev);
 
-   fimc_unregister_m2m_device(fimc);
-   fimc_unregister_capture_device(fimc);
-
vb2_dma_contig_cleanup_ctx(fimc-alloc_ctx);
 
clk_disable(fimc-clock[CLK_BUS]);
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h 
b/drivers/media/video/s5p-fimc/fimc-core.h
index 55c1410..c088dac 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.h
+++ b/drivers/media/video/s5p-fimc/fimc-core.h
@@ -644,6 +644,7 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx);
 int fimc_prepare_config(struct fimc_ctx *ctx, u32 flags);
 int fimc_prepare_addr(struct fimc_ctx *ctx, struct vb2_buffer *vb,
  struct fimc_frame *frame, struct fimc_addr *paddr);
+int fimc_register_m2m_device(struct fimc_dev *fimc);
 
 /* -*/
 /* fimc-capture.c  */
-- 
1.7.5.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 v3 14/19] s5p-fimc: Convert to use media pipeline operations

2011-07-04 Thread Sylwester Nawrocki
Add format negotiation routine for sensor subdevs not exposing
a device node.
TRY_FMT ioctl is completed by a subsequent patch adding the
capture subdev. This way the try_fmt routines can be common
for the subdev and the video node.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |  109 +--
 drivers/media/video/s5p-fimc/fimc-core.c|  125 +++
 drivers/media/video/s5p-fimc/fimc-core.h|   14 ++-
 drivers/media/video/s5p-fimc/fimc-reg.c |8 +-
 4 files changed, 125 insertions(+), 131 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index fb0d89a..ecb0246 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -74,11 +74,9 @@ static int fimc_start_capture(struct fimc_dev *fimc)
 
 static int fimc_stop_capture(struct fimc_dev *fimc)
 {
-   unsigned long flags;
-   struct fimc_vid_cap *cap;
+   struct fimc_vid_cap *cap = fimc-vid_cap;
struct fimc_vid_buffer *buf;
-
-   cap = fimc-vid_cap;
+   unsigned long flags;
 
if (!fimc_capture_active(fimc))
return 0;
@@ -92,11 +90,10 @@ static int fimc_stop_capture(struct fimc_dev *fimc)
   !test_bit(ST_CAPT_SHUT, fimc-state),
   FIMC_SHUTDOWN_TIMEOUT);
 
-   v4l2_subdev_call(cap-sd, video, s_stream, 0);
-
spin_lock_irqsave(fimc-slock, flags);
fimc-state = ~(1  ST_CAPT_RUN | 1  ST_CAPT_PEND |
-1  ST_CAPT_SHUT | 1  ST_CAPT_STREAM);
+1  ST_CAPT_SHUT | 1  ST_CAPT_STREAM |
+1  ST_CAPT_ISP_STREAM);
 
fimc-vid_cap.active_buf_cnt = 0;
 
@@ -112,9 +109,9 @@ static int fimc_stop_capture(struct fimc_dev *fimc)
}
 
spin_unlock_irqrestore(fimc-slock, flags);
-
dbg(state: 0x%lx, fimc-state);
-   return 0;
+
+   return fimc_pipeline_s_stream(fimc, 0);
 }
 
 int fimc_capture_suspend(struct fimc_dev *fimc)
@@ -197,15 +194,13 @@ static int buffer_prepare(struct vb2_buffer *vb)
return -EINVAL;
 
for (i = 0; i  ctx-d_frame.fmt-memplanes; i++) {
-   unsigned long size = get_plane_size(ctx-d_frame, i);
-
+   unsigned long size = ctx-d_frame.payload[i];
if (vb2_plane_size(vb, i)  size) {
v4l2_err(ctx-fimc_dev-vid_cap.vfd,
 User buffer too small (%ld  %ld)\n,
 vb2_plane_size(vb, i), size);
return -EINVAL;
}
-
vb2_set_plane_payload(vb, i, size);
}
 
@@ -214,10 +209,10 @@ static int buffer_prepare(struct vb2_buffer *vb)
 
 static void buffer_queue(struct vb2_buffer *vb)
 {
-   struct fimc_ctx *ctx = vb2_get_drv_priv(vb-vb2_queue);
-   struct fimc_dev *fimc = ctx-fimc_dev;
struct fimc_vid_buffer *buf
= container_of(vb, struct fimc_vid_buffer, vb);
+   struct fimc_ctx *ctx = vb2_get_drv_priv(vb-vb2_queue);
+   struct fimc_dev *fimc = ctx-fimc_dev;
struct fimc_vid_cap *vid_cap = fimc-vid_cap;
unsigned long flags;
int min_bufs;
@@ -244,9 +239,14 @@ static void buffer_queue(struct vb2_buffer *vb)
min_bufs = vid_cap-reqbufs_count  1 ? 2 : 1;
 
if (vid_cap-active_buf_cnt = min_bufs 
-   !test_and_set_bit(ST_CAPT_STREAM, fimc-state))
+   !test_and_set_bit(ST_CAPT_STREAM, fimc-state)) {
fimc_activate_capture(ctx);
+   spin_unlock_irqrestore(fimc-slock, flags);
 
+   if (!test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
+   fimc_pipeline_s_stream(fimc, 1);
+   return;
+   }
spin_unlock_irqrestore(fimc-slock, flags);
 }
 
@@ -309,15 +309,21 @@ static int fimc_capture_open(struct file *file)
if (fimc_m2m_active(fimc))
return -EBUSY;
 
-   ret = pm_runtime_get_sync(fimc-pdev-dev);
-   if (ret  0) {
-   v4l2_fh_release(file);
-   return ret;
-   }
-
-   if (++fimc-vid_cap.refcnt == 1)
+   pm_runtime_get_sync(fimc-pdev-dev);
+
+   if (++fimc-vid_cap.refcnt == 1) {
+   ret = fimc_pipeline_initialize(fimc,
+  fimc-vid_cap.vfd-entity, true);
+   if (ret  0) {
+   dev_err(fimc-pdev-dev,
+   Video pipeline initialization failed\n);
+   pm_runtime_put_sync(fimc-pdev-dev);
+   fimc-vid_cap.refcnt--;
+   v4l2_fh_release(file);
+   return ret;
+   }
ret = fimc_capture_ctrls_create(fimc);
-
+   }
return ret;
 }
 
@@ -329,10 

[PATCH v3 02/19] s5p-fimc: Add media entity initialization

2011-07-04 Thread Sylwester Nawrocki
Add intialization of the media entities for video capture
and mem-to-mem video nodes.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   28 --
 drivers/media/video/s5p-fimc/fimc-core.c|   27 +++--
 drivers/media/video/s5p-fimc/fimc-core.h|4 +++
 3 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index ea74e4b..c9be15c 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -838,9 +838,8 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
fr-width = fr-f_width = fr-o_width = 640;
fr-height = fr-f_height = fr-o_height = 480;
 
-   if (!v4l2_dev-name[0])
-   snprintf(v4l2_dev-name, sizeof(v4l2_dev-name),
-%s.capture, dev_name(fimc-pdev-dev));
+   snprintf(v4l2_dev-name, sizeof(v4l2_dev-name),
+%s.capture, dev_name(fimc-pdev-dev));
 
ret = v4l2_device_register(NULL, v4l2_dev);
if (ret)
@@ -852,11 +851,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
goto err_v4l2_reg;
}
 
-   snprintf(vfd-name, sizeof(vfd-name), %s:cap,
-dev_name(fimc-pdev-dev));
+   strlcpy(vfd-name, v4l2_dev-name, sizeof(vfd-name));
 
vfd-fops   = fimc_capture_fops;
vfd-ioctl_ops  = fimc_capture_ioctl_ops;
+   vfd-v4l2_dev   = v4l2_dev;
vfd-minor  = -1;
vfd-release= video_device_release;
vfd-lock   = fimc-lock;
@@ -886,6 +885,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
 
vb2_queue_init(q);
 
+   fimc-vid_cap.vd_pad.flags = MEDIA_PAD_FL_SINK;
+   ret = media_entity_init(vfd-entity, 1, fimc-vid_cap.vd_pad, 0);
+   if (ret)
+   goto err_ent;
+
ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
if (ret) {
v4l2_err(v4l2_dev, Failed to register video device\n);
@@ -895,10 +899,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
v4l2_info(v4l2_dev,
  FIMC capture driver registered as /dev/video%d\n,
  vfd-num);
-
return 0;
 
 err_vd_reg:
+   media_entity_cleanup(vfd-entity);
+err_ent:
video_device_release(vfd);
 err_v4l2_reg:
v4l2_device_unregister(v4l2_dev);
@@ -910,10 +915,11 @@ err_info:
 
 void fimc_unregister_capture_device(struct fimc_dev *fimc)
 {
-   struct fimc_vid_cap *capture = fimc-vid_cap;
+   struct video_device *vfd = fimc-vid_cap.vfd;
 
-   if (capture-vfd)
-   video_unregister_device(capture-vfd);
-
-   kfree(capture-ctx);
+   if (vfd) {
+   media_entity_cleanup(vfd-entity);
+   video_unregister_device(vfd);
+   }
+   kfree(fimc-vid_cap.ctx);
 }
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index 12e2d19..c97494d 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -1507,10 +1507,8 @@ static int fimc_register_m2m_device(struct fimc_dev 
*fimc)
pdev = fimc-pdev;
v4l2_dev = fimc-m2m.v4l2_dev;
 
-   /* set name if it is empty */
-   if (!v4l2_dev-name[0])
-   snprintf(v4l2_dev-name, sizeof(v4l2_dev-name),
-%s.m2m, dev_name(pdev-dev));
+   snprintf(v4l2_dev-name, sizeof(v4l2_dev-name),
+%s.m2m, dev_name(pdev-dev));
 
ret = v4l2_device_register(pdev-dev, v4l2_dev);
if (ret)
@@ -1524,6 +1522,7 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc)
 
vfd-fops   = fimc_m2m_fops;
vfd-ioctl_ops  = fimc_m2m_ioctl_ops;
+   vfd-v4l2_dev   = v4l2_dev;
vfd-minor  = -1;
vfd-release= video_device_release;
vfd-lock   = fimc-lock;
@@ -1541,17 +1540,22 @@ static int fimc_register_m2m_device(struct fimc_dev 
*fimc)
goto err_m2m_r2;
}
 
+   ret = media_entity_init(vfd-entity, 0, NULL, 0);
+   if (ret)
+   goto err_m2m_r3;
+
ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
if (ret) {
v4l2_err(v4l2_dev,
 %s(): failed to register video device\n, __func__);
-   goto err_m2m_r3;
+   goto err_m2m_r4;
}
v4l2_info(v4l2_dev,
  FIMC m2m driver registered as /dev/video%d\n, vfd-num);
 
return 0;
-
+err_m2m_r4:
+   media_entity_cleanup(vfd-entity);
 err_m2m_r3:
v4l2_m2m_release(fimc-m2m.m2m_dev);
 err_m2m_r2:
@@ -1564,12 +1568,13 @@ err_m2m_r1:
 
 void fimc_unregister_m2m_device(struct fimc_dev *fimc)
 {
-   if (fimc) {
-   

[PATCH v3 08/19] s5p-fimc: Add the media device driver

2011-07-04 Thread Sylwester Nawrocki
The fimc media device driver is hooked onto s5p-fimc-md platform device.
Such a platform device need to be added in a board initialization code
and then camera sensors need to be specified as it's platform data.
The s5p-fimc-md device is a top level entity for all FIMC, mipi-csis
and sensor devices.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/Kconfig |2 +-
 drivers/media/video/s5p-fimc/Makefile   |2 +-
 drivers/media/video/s5p-fimc/fimc-core.c|   33 +-
 drivers/media/video/s5p-fimc/fimc-core.h|   16 +-
 drivers/media/video/s5p-fimc/fimc-mdevice.c |  804 +++
 drivers/media/video/s5p-fimc/fimc-mdevice.h |  118 
 include/media/s5p_fimc.h|2 +
 7 files changed, 956 insertions(+), 21 deletions(-)
 create mode 100644 drivers/media/video/s5p-fimc/fimc-mdevice.c
 create mode 100644 drivers/media/video/s5p-fimc/fimc-mdevice.h

diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 2cc9552..d5ad61b 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -935,7 +935,7 @@ config VIDEO_MX2
 
 config  VIDEO_SAMSUNG_S5P_FIMC
tristate Samsung S5P and EXYNOS4 camera host interface driver
-   depends on VIDEO_DEV  VIDEO_V4L2  PLAT_S5P
+   depends on VIDEO_DEV  VIDEO_V4L2  PLAT_S5P  I2C  
VIDEO_V4L2_SUBDEV_API
select VIDEOBUF2_DMA_CONTIG
select V4L2_MEM2MEM_DEV
---help---
diff --git a/drivers/media/video/s5p-fimc/Makefile 
b/drivers/media/video/s5p-fimc/Makefile
index df6954a..33dec7f 100644
--- a/drivers/media/video/s5p-fimc/Makefile
+++ b/drivers/media/video/s5p-fimc/Makefile
@@ -1,4 +1,4 @@
-s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-capture.o
+s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-capture.o fimc-mdevice.o
 s5p-csis-objs := mipi-csis.o
 
 obj-$(CONFIG_VIDEO_S5P_MIPI_CSIS)  += s5p-csis.o
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index 8e2f2ee..59190aa 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -28,6 +28,7 @@
 #include media/videobuf2-dma-contig.h
 
 #include fimc-core.h
+#include fimc-mdevice.h
 
 static char *fimc_clocks[MAX_FIMC_CLOCKS] = {
sclk_fimc, fimc
@@ -1876,6 +1877,7 @@ static struct fimc_pix_limit s5p_pix_limit[4] = {
 static struct samsung_fimc_variant fimc0_variant_s5p = {
.has_inp_rot = 1,
.has_out_rot = 1,
+   .has_cam_if  = 1,
.min_inp_pixsize = 16,
.min_out_pixsize = 16,
.hor_offs_align  = 8,
@@ -1884,6 +1886,7 @@ static struct samsung_fimc_variant fimc0_variant_s5p = {
 };
 
 static struct samsung_fimc_variant fimc2_variant_s5p = {
+   .has_cam_if  = 1,
.min_inp_pixsize = 16,
.min_out_pixsize = 16,
.hor_offs_align  = 8,
@@ -1895,6 +1898,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv210 
= {
.pix_hoff= 1,
.has_inp_rot = 1,
.has_out_rot = 1,
+   .has_cam_if  = 1,
.min_inp_pixsize = 16,
.min_out_pixsize = 16,
.hor_offs_align  = 8,
@@ -1906,6 +1910,7 @@ static struct samsung_fimc_variant fimc1_variant_s5pv210 
= {
.pix_hoff= 1,
.has_inp_rot = 1,
.has_out_rot = 1,
+   .has_cam_if  = 1,
.has_mainscaler_ext = 1,
.min_inp_pixsize = 16,
.min_out_pixsize = 16,
@@ -1915,6 +1920,7 @@ static struct samsung_fimc_variant fimc1_variant_s5pv210 
= {
 };
 
 static struct samsung_fimc_variant fimc2_variant_s5pv210 = {
+   .has_cam_if  = 1,
.pix_hoff= 1,
.min_inp_pixsize = 16,
.min_out_pixsize = 16,
@@ -1927,6 +1933,7 @@ static struct samsung_fimc_variant fimc0_variant_exynos4 
= {
.pix_hoff= 1,
.has_inp_rot = 1,
.has_out_rot = 1,
+   .has_cam_if  = 1,
.has_cistatus2   = 1,
.has_mainscaler_ext = 1,
.min_inp_pixsize = 16,
@@ -1936,8 +1943,9 @@ static struct samsung_fimc_variant fimc0_variant_exynos4 
= {
.pix_limit   = s5p_pix_limit[1],
 };
 
-static struct samsung_fimc_variant fimc2_variant_exynos4 = {
+static struct samsung_fimc_variant fimc3_variant_exynos4 = {
.pix_hoff= 1,
+   .has_cam_if  = 1,
.has_cistatus2   = 1,
.has_mainscaler_ext = 1,
.min_inp_pixsize = 16,
@@ -1975,7 +1983,7 @@ static struct samsung_fimc_driverdata 
fimc_drvdata_exynos4 = {
[0] = fimc0_variant_exynos4,
[1] = fimc0_variant_exynos4,
[2] = fimc0_variant_exynos4,
-   [3] = fimc2_variant_exynos4,
+   [3] = fimc3_variant_exynos4,
},
.num_entities = 4,
.lclk_frequency = 16600UL,
@@ -2003,32 +2011,21 @@ static const struct dev_pm_ops fimc_pm_ops = {
 
 

[PATCH v3 01/19] s5p-fimc: Add support for runtime PM in the mem-to-mem driver

2011-07-04 Thread Sylwester Nawrocki
Only the FIMC entity memory-to-memory operation is fully covered,
for the camera capture suspend/resume only stubs are provided.
It's all what is needed to enable the driver on EXYNOS4 series with
power domain driver enabled. Camera capture pipeline suspend/resume
is covered by a separate patch.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   18 ++
 drivers/media/video/s5p-fimc/fimc-core.c|  273 ---
 drivers/media/video/s5p-fimc/fimc-core.h|   16 +-
 drivers/media/video/s5p-fimc/fimc-reg.c |2 +-
 4 files changed, 231 insertions(+), 78 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index 0d730e5..ea74e4b 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -17,6 +17,7 @@
 #include linux/interrupt.h
 #include linux/device.h
 #include linux/platform_device.h
+#include linux/pm_runtime.h
 #include linux/list.h
 #include linux/slab.h
 #include linux/clk.h
@@ -196,6 +197,16 @@ static int fimc_stop_capture(struct fimc_dev *fimc)
return 0;
 }
 
+int fimc_capture_suspend(struct fimc_dev *fimc)
+{
+   return -EBUSY;
+}
+
+int fimc_capture_resume(struct fimc_dev *fimc)
+{
+   return 0;
+}
+
 static int start_streaming(struct vb2_queue *q)
 {
struct fimc_ctx *ctx = q-drv_priv;
@@ -381,9 +392,14 @@ static int fimc_capture_open(struct file *file)
if (fimc_m2m_active(fimc))
return -EBUSY;
 
+   ret = pm_runtime_get_sync(fimc-pdev-dev);
+   if (ret)
+   return ret;
+
if (++fimc-vid_cap.refcnt == 1) {
ret = fimc_isp_subdev_init(fimc, 0);
if (ret) {
+   pm_runtime_put_sync(fimc-pdev-dev);
fimc-vid_cap.refcnt--;
return -EIO;
}
@@ -411,6 +427,8 @@ static int fimc_capture_close(struct file *file)
fimc_subdev_unregister(fimc);
}
 
+   pm_runtime_put_sync(fimc-pdev-dev);
+
return 0;
 }
 
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c 
b/drivers/media/video/s5p-fimc/fimc-core.c
index aa55066..12e2d19 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -18,6 +18,7 @@
 #include linux/interrupt.h
 #include linux/device.h
 #include linux/platform_device.h
+#include linux/pm_runtime.h
 #include linux/list.h
 #include linux/io.h
 #include linux/slab.h
@@ -301,7 +302,6 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx)
 static void fimc_m2m_job_finish(struct fimc_ctx *ctx, int vb_state)
 {
struct vb2_buffer *src_vb, *dst_vb;
-   struct fimc_dev *fimc = ctx-fimc_dev;
 
if (!ctx || !ctx-m2m_ctx)
return;
@@ -312,43 +312,52 @@ static void fimc_m2m_job_finish(struct fimc_ctx *ctx, int 
vb_state)
if (src_vb  dst_vb) {
v4l2_m2m_buf_done(src_vb, vb_state);
v4l2_m2m_buf_done(dst_vb, vb_state);
-   v4l2_m2m_job_finish(fimc-m2m.m2m_dev, ctx-m2m_ctx);
+   v4l2_m2m_job_finish(ctx-fimc_dev-m2m.m2m_dev,
+   ctx-m2m_ctx);
}
 }
 
 /* Complete the transaction which has been scheduled for execution. */
-static void fimc_m2m_shutdown(struct fimc_ctx *ctx)
+static int fimc_m2m_shutdown(struct fimc_ctx *ctx)
 {
struct fimc_dev *fimc = ctx-fimc_dev;
int ret;
 
if (!fimc_m2m_pending(fimc))
-   return;
+   return 0;
 
fimc_ctx_state_lock_set(FIMC_CTX_SHUT, ctx);
 
ret = wait_event_timeout(fimc-irq_queue,
   !fimc_ctx_state_is_set(FIMC_CTX_SHUT, ctx),
   FIMC_SHUTDOWN_TIMEOUT);
-   /*
-* In case of a timeout the buffers are not released in the interrupt
-* handler so return them here with the error flag set, if there are
-* any on the queue.
-*/
-   if (ret == 0)
-   fimc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
+
+   return ret == 0 ? -ETIMEDOUT : ret;
+}
+
+static int start_streaming(struct vb2_queue *q)
+{
+   struct fimc_ctx *ctx = q-drv_priv;
+   int ret;
+
+   ret = pm_runtime_get_sync(ctx-fimc_dev-pdev-dev);
+   return ret  0 ? 0 : ret;
 }
 
 static int stop_streaming(struct vb2_queue *q)
 {
struct fimc_ctx *ctx = q-drv_priv;
+   int ret;
 
-   fimc_m2m_shutdown(ctx);
+   ret = fimc_m2m_shutdown(ctx);
+   if (ret == -ETIMEDOUT)
+   fimc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR);
 
+   pm_runtime_put(ctx-fimc_dev-pdev-dev);
return 0;
 }
 
-static void fimc_capture_irq_handler(struct fimc_dev *fimc)
+void fimc_capture_irq_handler(struct fimc_dev *fimc)
 {
struct fimc_vid_cap *cap = fimc-vid_cap;
struct 

[PATCH v3 11/19] s5p-fimc: Add media operations in the capture entity driver

2011-07-04 Thread Sylwester Nawrocki
Add the link_setup handler for the camera capture video node.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   32 +++
 drivers/media/video/s5p-fimc/fimc-core.h|2 +
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index b193b7e..7c6c420 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -650,6 +650,37 @@ static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops 
= {
.vidioc_g_input = fimc_cap_g_input,
 };
 
+/* Media operations */
+static int fimc_link_setup(struct media_entity *entity,
+  const struct media_pad *local,
+  const struct media_pad *remote, u32 flags)
+{
+   struct video_device *vd = media_entity_to_video_device(entity);
+   struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(remote-entity);
+   struct fimc_dev *fimc = video_get_drvdata(vd);
+
+   if (WARN_ON(fimc == NULL))
+   return 0;
+
+   dbg(%s -- %s, flags: 0x%x. input: 0x%x,
+   local-entity-name, remote-entity-name, flags,
+   fimc-vid_cap.input);
+
+   if (flags  MEDIA_LNK_FL_ENABLED) {
+   if (fimc-vid_cap.input != 0)
+   return -EBUSY;
+   fimc-vid_cap.input = sd-grp_id;
+   return 0;
+   }
+
+   fimc-vid_cap.input = 0;
+   return 0;
+}
+
+static const struct media_entity_operations fimc_media_ops = {
+   .link_setup = fimc_link_setup,
+};
+
 /* fimc-lock must be already initialized */
 int fimc_register_capture_device(struct fimc_dev *fimc,
 struct v4l2_device *v4l2_dev)
@@ -724,6 +755,7 @@ int fimc_register_capture_device(struct fimc_dev *fimc,
if (ret)
goto err_ent;
 
+   vfd-entity.ops = fimc_media_ops;
vfd-ctrl_handler = ctx-ctrl_handler;
ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
if (ret) {
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h 
b/drivers/media/video/s5p-fimc/fimc-core.h
index 3606369..86288c8 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.h
+++ b/drivers/media/video/s5p-fimc/fimc-core.h
@@ -305,6 +305,7 @@ struct fimc_m2m_device {
  * @reqbufs_count: the number of buffers requested in REQBUFS ioctl
  * @input_index: input (camera sensor) index
  * @refcnt: driver's private reference counter
+ * @input: capture input type, grp_id of attached subdev
  * @vid_dev_compat: true to enable full pipeline setup in the driver
  */
 struct fimc_vid_cap {
@@ -323,6 +324,7 @@ struct fimc_vid_cap {
unsigned intreqbufs_count;
int input_index;
int refcnt;
+   u32 input;
boolvid_dev_compat;
 };
 
-- 
1.7.5.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 v3 07/19] s5p-fimc: Remove v4l2_device from video capture and m2m driver

2011-07-04 Thread Sylwester Nawrocki
Currently there is a v4l2_device instance being registered per each
(capture and memory-to-memory) video node created per FIMC H/W instance.
This patch is a prerequisite for using the top level v4l2_device
instantiated by the media device driver.
To retain current debug trace semantic (so it's possible to distinguish
between the capture and m2m FIMC) the video_device is used in place
of v4l2_device where appropriate.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   43 ++--
 drivers/media/video/s5p-fimc/fimc-core.c|   70 ++
 drivers/media/video/s5p-fimc/fimc-core.h|   15 +++---
 drivers/media/video/s5p-fimc/fimc-reg.c |7 ++-
 4 files changed, 55 insertions(+), 80 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index e7aa61e..70892e4 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -130,7 +130,6 @@ static int start_streaming(struct vb2_queue *q)
fimc-vid_cap.buf_index = 0;
 
set_bit(ST_CAPT_PEND, fimc-state);
-
return 0;
 }
 
@@ -177,7 +176,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
 {
struct vb2_queue *vq = vb-vb2_queue;
struct fimc_ctx *ctx = vq-drv_priv;
-   struct v4l2_device *v4l2_dev = ctx-fimc_dev-m2m.v4l2_dev;
int i;
 
if (!ctx-d_frame.fmt || vq-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
@@ -187,7 +185,8 @@ static int buffer_prepare(struct vb2_buffer *vb)
unsigned long size = get_plane_size(ctx-d_frame, i);
 
if (vb2_plane_size(vb, i)  size) {
-   v4l2_err(v4l2_dev, User buffer too small (%ld  
%ld)\n,
+   v4l2_err(ctx-fimc_dev-vid_cap.vfd,
+User buffer too small (%ld  %ld)\n,
 vb2_plane_size(vb, i), size);
return -EINVAL;
}
@@ -398,7 +397,8 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void 
*priv,
pix = f-fmt.pix_mp;
frame-fmt = find_format(f, FMT_FLAGS_M2M | FMT_FLAGS_CAM);
if (!frame-fmt) {
-   err(fimc target format not found\n);
+   v4l2_err(fimc-vid_cap.vfd,
+Not supported capture (FIMC target) color format\n);
return -EINVAL;
}
 
@@ -458,7 +458,7 @@ static int fimc_cap_streamon(struct file *file, void *priv,
return -EBUSY;
 
if (!(ctx-state  FIMC_DST_FMT)) {
-   v4l2_err(fimc-vid_cap.v4l2_dev, Format is not set\n);
+   v4l2_err(fimc-vid_cap.vfd, Format is not set\n);
return -EINVAL;
}
 
@@ -588,9 +588,8 @@ static int fimc_cap_s_crop(struct file *file, void *fh,
return ret;
 
if (!(ctx-state  FIMC_DST_FMT)) {
-   v4l2_err(fimc-vid_cap.v4l2_dev,
-Capture color format not set\n);
-   return -EINVAL; /* TODO: make sure this is the right value */
+   v4l2_err(fimc-vid_cap.vfd, Capture format is not set\n);
+   return -EINVAL;
}
 
f = ctx-s_frame;
@@ -599,7 +598,7 @@ static int fimc_cap_s_crop(struct file *file, void *fh,
  ctx-d_frame.width, ctx-d_frame.height,
  ctx-rotation);
if (ret) {
-   v4l2_err(fimc-vid_cap.v4l2_dev, Out of the scaler range\n);
+   v4l2_err(fimc-vid_cap.vfd, Out of the scaler range\n);
return ret;
}
 
@@ -643,16 +642,16 @@ static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops 
= {
 };
 
 /* fimc-lock must be already initialized */
-int fimc_register_capture_device(struct fimc_dev *fimc)
+int fimc_register_capture_device(struct fimc_dev *fimc,
+struct v4l2_device *v4l2_dev)
 {
-   struct v4l2_device *v4l2_dev = fimc-vid_cap.v4l2_dev;
struct video_device *vfd;
struct fimc_vid_cap *vid_cap;
struct fimc_ctx *ctx;
struct v4l2_format f;
struct fimc_frame *fr;
struct vb2_queue *q;
-   int ret;
+   int ret = -ENOMEM;
 
ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
if (!ctx)
@@ -670,20 +669,14 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
fr-width = fr-f_width = fr-o_width = 640;
fr-height = fr-f_height = fr-o_height = 480;
 
-   snprintf(v4l2_dev-name, sizeof(v4l2_dev-name),
-%s.capture, dev_name(fimc-pdev-dev));
-
-   ret = v4l2_device_register(NULL, v4l2_dev);
-   if (ret)
-   goto err_info;
-
vfd = video_device_alloc();
if (!vfd) {
v4l2_err(v4l2_dev, Failed to allocate video device\n);
-   goto err_v4l2_reg;
+

[PATCH v3 06/19] s5p-fimc: Remove sensor management code from FIMC capture driver

2011-07-04 Thread Sylwester Nawrocki
The sensor subdevs need to be shared between all available FIMC instances.
Remove their registration from FIMC capture driver so they can then be
registered to the media device driver.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |  139 +--
 drivers/media/video/s5p-fimc/fimc-core.h|2 +-
 2 files changed, 2 insertions(+), 139 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index 5b08b69..e7aa61e 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -16,12 +16,9 @@
 #include linux/bug.h
 #include linux/interrupt.h
 #include linux/device.h
-#include linux/platform_device.h
 #include linux/pm_runtime.h
 #include linux/list.h
 #include linux/slab.h
-#include linux/clk.h
-#include linux/i2c.h
 
 #include linux/videodev2.h
 #include media/v4l2-device.h
@@ -32,126 +29,6 @@
 
 #include fimc-core.h
 
-static struct v4l2_subdev *fimc_subdev_register(struct fimc_dev *fimc,
-   struct s5p_fimc_isp_info *isp_info)
-{
-   struct i2c_adapter *i2c_adap;
-   struct fimc_vid_cap *vid_cap = fimc-vid_cap;
-   struct v4l2_subdev *sd = NULL;
-
-   i2c_adap = i2c_get_adapter(isp_info-i2c_bus_num);
-   if (!i2c_adap)
-   return ERR_PTR(-ENOMEM);
-
-   sd = v4l2_i2c_new_subdev_board(vid_cap-v4l2_dev, i2c_adap,
-  isp_info-board_info, NULL);
-   if (!sd) {
-   v4l2_err(vid_cap-v4l2_dev, failed to acquire subdev\n);
-   return NULL;
-   }
-
-   v4l2_info(vid_cap-v4l2_dev, subdevice %s registered successfuly\n,
-   isp_info-board_info-type);
-
-   return sd;
-}
-
-static void fimc_subdev_unregister(struct fimc_dev *fimc)
-{
-   struct fimc_vid_cap *vid_cap = fimc-vid_cap;
-   struct i2c_client *client;
-
-   if (vid_cap-input_index  0)
-   return; /* Subdevice already released or not registered. */
-
-   if (vid_cap-sd) {
-   v4l2_device_unregister_subdev(vid_cap-sd);
-   client = v4l2_get_subdevdata(vid_cap-sd);
-   i2c_unregister_device(client);
-   i2c_put_adapter(client-adapter);
-   vid_cap-sd = NULL;
-   }
-
-   vid_cap-input_index = -1;
-}
-
-/**
- * fimc_subdev_attach - attach v4l2_subdev to camera host interface
- *
- * @fimc: FIMC device information
- * @index: index to the array of available subdevices,
- *-1 for full array search or non negative value
- *to select specific subdevice
- */
-static int fimc_subdev_attach(struct fimc_dev *fimc, int index)
-{
-   struct fimc_vid_cap *vid_cap = fimc-vid_cap;
-   struct s5p_platform_fimc *pdata = fimc-pdata;
-   struct s5p_fimc_isp_info *isp_info;
-   struct v4l2_subdev *sd;
-   int i;
-
-   for (i = 0; i  pdata-num_clients; ++i) {
-   isp_info = pdata-isp_info[i];
-
-   if (index = 0  i != index)
-   continue;
-
-   sd = fimc_subdev_register(fimc, isp_info);
-   if (!IS_ERR_OR_NULL(sd)) {
-   vid_cap-sd = sd;
-   vid_cap-input_index = i;
-
-   return 0;
-   }
-   }
-
-   vid_cap-input_index = -1;
-   vid_cap-sd = NULL;
-   v4l2_err(vid_cap-v4l2_dev, fimc%d: sensor attach failed\n,
-fimc-id);
-   return -ENODEV;
-}
-
-static int fimc_isp_subdev_init(struct fimc_dev *fimc, unsigned int index)
-{
-   struct s5p_fimc_isp_info *isp_info;
-   struct s5p_platform_fimc *pdata = fimc-pdata;
-   int ret;
-
-   if (index = pdata-num_clients)
-   return -EINVAL;
-
-   isp_info = pdata-isp_info[index];
-
-   if (isp_info-clk_frequency)
-   clk_set_rate(fimc-clock[CLK_CAM], isp_info-clk_frequency);
-
-   ret = clk_enable(fimc-clock[CLK_CAM]);
-   if (ret)
-   return ret;
-
-   ret = fimc_subdev_attach(fimc, index);
-   if (ret)
-   return ret;
-
-   ret = fimc_hw_set_camera_polarity(fimc, isp_info);
-   if (ret)
-   return ret;
-
-   ret = v4l2_subdev_call(fimc-vid_cap.sd, core, s_power, 1);
-   if (!ret)
-   return ret;
-
-   /* enabling power failed so unregister subdev */
-   fimc_subdev_unregister(fimc);
-
-   v4l2_err(fimc-vid_cap.v4l2_dev, ISP initialization failed: %d\n,
-ret);
-
-   return ret;
-}
-
 static int fimc_stop_capture(struct fimc_dev *fimc)
 {
unsigned long flags;
@@ -396,15 +273,7 @@ static int fimc_capture_open(struct file *file)
if (ret)
return ret;
 
-   if (++fimc-vid_cap.refcnt == 1) {
-   ret = fimc_isp_subdev_init(fimc, 0);

[PATCH v3 09/19] s5p-fimc: Conversion to use struct v4l2_fh

2011-07-04 Thread Sylwester Nawrocki
This is a prerequisite for the patch converting the driver to use
the control framework. As the capture driver does not use per file
handle contexts, two separate ioctl handlers are created for it
(vidioc_try_fmt_mplane, and vidioc_g_fmt_mplane) so there is no
handlers shared between the memory-to-memory and capture video node.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |  114 +
 drivers/media/video/s5p-fimc/fimc-core.c|  182 +++
 drivers/media/video/s5p-fimc/fimc-core.h|   10 +-
 3 files changed, 168 insertions(+), 138 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index 70892e4..0ceb16d 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -260,7 +260,10 @@ static struct vb2_ops fimc_capture_qops = {
 static int fimc_capture_open(struct file *file)
 {
struct fimc_dev *fimc = video_drvdata(file);
-   int ret = 0;
+   int ret = v4l2_fh_open(file);
+
+   if (ret)
+   return ret;
 
dbg(pid: %d, state: 0x%lx, task_pid_nr(current), fimc-state);
 
@@ -269,11 +272,12 @@ static int fimc_capture_open(struct file *file)
return -EBUSY;
 
ret = pm_runtime_get_sync(fimc-pdev-dev);
-   if (ret)
+   if (ret  0) {
+   v4l2_fh_release(file);
return ret;
+   }
 
++fimc-vid_cap.refcnt;
-   file-private_data = fimc-vid_cap.ctx;
 
return 0;
 }
@@ -291,22 +295,20 @@ static int fimc_capture_close(struct file *file)
 
pm_runtime_put_sync(fimc-pdev-dev);
 
-   return 0;
+   return v4l2_fh_release(file);
 }
 
 static unsigned int fimc_capture_poll(struct file *file,
  struct poll_table_struct *wait)
 {
-   struct fimc_ctx *ctx = file-private_data;
-   struct fimc_dev *fimc = ctx-fimc_dev;
+   struct fimc_dev *fimc = video_drvdata(file);
 
return vb2_poll(fimc-vid_cap.vbq, file, wait);
 }
 
 static int fimc_capture_mmap(struct file *file, struct vm_area_struct *vma)
 {
-   struct fimc_ctx *ctx = file-private_data;
-   struct fimc_dev *fimc = ctx-fimc_dev;
+   struct fimc_dev *fimc = video_drvdata(file);
 
return vb2_mmap(fimc-vid_cap.vbq, vma);
 }
@@ -324,8 +326,7 @@ static const struct v4l2_file_operations fimc_capture_fops 
= {
 static int fimc_vidioc_querycap_capture(struct file *file, void *priv,
struct v4l2_capability *cap)
 {
-   struct fimc_ctx *ctx = file-private_data;
-   struct fimc_dev *fimc = ctx-fimc_dev;
+   struct fimc_dev *fimc = video_drvdata(file);
 
strncpy(cap-driver, fimc-pdev-name, sizeof(cap-driver) - 1);
strncpy(cap-card, fimc-pdev-name, sizeof(cap-card) - 1);
@@ -372,20 +373,41 @@ static int sync_capture_fmt(struct fimc_ctx *ctx)
return 0;
 }
 
+static int fimc_cap_g_fmt_mplane(struct file *file, void *fh,
+struct v4l2_format *f)
+{
+   struct fimc_dev *fimc = video_drvdata(file);
+   struct fimc_ctx *ctx = fimc-vid_cap.ctx;
+
+   if (f-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+   return -EINVAL;
+
+   return fimc_fill_format(ctx-d_frame, f);
+}
+
+static int fimc_cap_try_fmt_mplane(struct file *file, void *fh,
+  struct v4l2_format *f)
+{
+   struct fimc_dev *fimc = video_drvdata(file);
+   struct fimc_ctx *ctx = fimc-vid_cap.ctx;
+
+   return fimc_try_fmt_mplane(ctx, f);
+}
+
 static int fimc_cap_s_fmt_mplane(struct file *file, void *priv,
 struct v4l2_format *f)
 {
-   struct fimc_ctx *ctx = priv;
-   struct fimc_dev *fimc = ctx-fimc_dev;
-   struct fimc_frame *frame;
+   struct fimc_dev *fimc = video_drvdata(file);
+   struct fimc_ctx *ctx = fimc-vid_cap.ctx;
struct v4l2_pix_format_mplane *pix;
+   struct fimc_frame *frame;
int ret;
int i;
 
if (f-type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
return -EINVAL;
 
-   ret = fimc_vidioc_try_fmt_mplane(file, priv, f);
+   ret = fimc_try_fmt_mplane(ctx, f);
if (ret)
return ret;
 
@@ -427,7 +449,7 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void 
*priv,
 static int fimc_cap_enum_input(struct file *file, void *priv,
   struct v4l2_input *i)
 {
-   struct fimc_ctx *ctx = priv;
+   struct fimc_dev *fimc = video_drvdata(file);
 
if (i-index != 0)
return -EINVAL;
@@ -451,8 +473,8 @@ static int fimc_cap_g_input(struct file *file, void *priv, 
unsigned int *i)
 static int fimc_cap_streamon(struct file *file, void *priv,
 enum v4l2_buf_type type)
 {
-   

[PATCH v3 05/19] s5p-fimc: Limit number of available inputs to one

2011-07-04 Thread Sylwester Nawrocki
Camera sensors at FIMC input are no longer selected with S_INPUT ioctl.
They will be attached to required FIMC entity through pipeline
re-configuration at the media device level.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-fimc/fimc-capture.c |   43 ---
 1 files changed, 6 insertions(+), 37 deletions(-)

diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c 
b/drivers/media/video/s5p-fimc/fimc-capture.c
index a806e48..5b08b69 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -562,57 +562,26 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void 
*priv,
 }
 
 static int fimc_cap_enum_input(struct file *file, void *priv,
-struct v4l2_input *i)
+  struct v4l2_input *i)
 {
struct fimc_ctx *ctx = priv;
-   struct s5p_platform_fimc *pldata = ctx-fimc_dev-pdata;
-   struct s5p_fimc_isp_info *isp_info;
 
-   if (i-index = pldata-num_clients)
+   if (i-index != 0)
return -EINVAL;
 
-   isp_info = pldata-isp_info[i-index];
 
i-type = V4L2_INPUT_TYPE_CAMERA;
-   strncpy(i-name, isp_info-board_info-type, 32);
return 0;
 }
 
-static int fimc_cap_s_input(struct file *file, void *priv,
- unsigned int i)
+static int fimc_cap_s_input(struct file *file, void *priv, unsigned int i)
 {
-   struct fimc_ctx *ctx = priv;
-   struct fimc_dev *fimc = ctx-fimc_dev;
-   struct s5p_platform_fimc *pdata = fimc-pdata;
-
-   if (fimc_capture_active(ctx-fimc_dev))
-   return -EBUSY;
-
-   if (i = pdata-num_clients)
-   return -EINVAL;
-
-
-   if (fimc-vid_cap.sd) {
-   int ret = v4l2_subdev_call(fimc-vid_cap.sd, core, s_power, 0);
-   if (ret)
-   err(s_power failed: %d, ret);
-
-   clk_disable(fimc-clock[CLK_CAM]);
-   }
-
-   /* Release the attached sensor subdevice. */
-   fimc_subdev_unregister(fimc);
-
-   return fimc_isp_subdev_init(fimc, i);
+   return i == 0 ? i : -EINVAL;
 }
 
-static int fimc_cap_g_input(struct file *file, void *priv,
-  unsigned int *i)
+static int fimc_cap_g_input(struct file *file, void *priv, unsigned int *i)
 {
-   struct fimc_ctx *ctx = priv;
-   struct fimc_vid_cap *cap = ctx-fimc_dev-vid_cap;
-
-   *i = cap-input_index;
+   *i = 0;
return 0;
 }
 
-- 
1.7.5.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


[cron job] v4l-dvb daily build: ERRORS

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

Results of the daily build of v4l-dvb:

date:Mon Jul  4 19:00:34 CEST 2011
git hash:df6aabbeb2b8799d97f3886fc994c318bc6a6843
gcc version:  i686-linux-gcc (GCC) 4.5.1
host hardware:x86_64
host os:  2.6.32.5

linux-git-armv5: WARNINGS
linux-git-armv5-davinci: WARNINGS
linux-git-armv5-ixp: WARNINGS
linux-git-armv5-omap2: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: OK
linux-git-mips: WARNINGS
linux-git-powerpc64: WARNINGS
linux-git-x86_64: WARNINGS
linux-2.6.31.12-i686: ERRORS
linux-2.6.32.6-i686: WARNINGS
linux-2.6.33-i686: WARNINGS
linux-2.6.34-i686: WARNINGS
linux-2.6.35.3-i686: WARNINGS
linux-2.6.36-i686: WARNINGS
linux-2.6.37-i686: WARNINGS
linux-2.6.38.2-i686: WARNINGS
linux-2.6.39.1-i686: WARNINGS
linux-2.6.31.12-x86_64: ERRORS
linux-2.6.32.6-x86_64: WARNINGS
linux-2.6.33-x86_64: WARNINGS
linux-2.6.34-x86_64: WARNINGS
linux-2.6.35.3-x86_64: WARNINGS
linux-2.6.36-x86_64: WARNINGS
linux-2.6.37-x86_64: WARNINGS
linux-2.6.38.2-x86_64: WARNINGS
linux-2.6.39.1-x86_64: WARNINGS
spec-git: ERRORS
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

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

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


Re: linux-next: Tree for July 4 (media/radio)

2011-07-04 Thread Randy Dunlap
On Mon, 4 Jul 2011 17:09:52 +1000 Stephen Rothwell wrote:

 Hi all,
 
 Changes since 20110701:
 
 The v4l-dvb tree gained a build failure so I used the version from
 next-20110701.


drivers/media/radio/radio-rtrack2.c:31:17: error: invalid suffix c on integer 
constant
make[4]: [drivers/media/radio/radio-rtrack2.o] Error 1 (ignored)
drivers/media/radio/radio-aimslab.c:49:17: error: invalid suffix f on integer 
constant
make[4]: [drivers/media/radio/radio-aimslab.o] Error 1 (ignored)
drivers/media/radio/radio-gemtek.c:51:18: error: invalid suffix c on integer 
constant
make[4]: [drivers/media/radio/radio-gemtek.o] Error 1 (ignored)
drivers/media/radio/radio-zoltrix.c:51:17: error: invalid suffix c on integer 
constant


These drivers do not handle hex CONFIG_ values correctly.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
--
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


gspca: video0 becomes video1 after ISOC data error

2011-07-04 Thread Németh Márton
Hi,

I'm running Debian with Linux 2.6.38-2-486 on a computer. I have a hama AC-150 
webcam
attached to this computer. The webcam works continouosly and I use mencoder to 
do some
cropping and transformation and to encode the video stream to a file.

When I plug the device the following appears in the dmesg:

[439884.692090] usb 3-1: new full speed USB device using uhci_hcd and address 6
[439884.841721] usb 3-1: New USB device found, idVendor=0c45, idProduct=6142
[439884.841958] usb 3-1: New USB device strings: Mfr=0, Product=1, 
SerialNumber=0
[439884.842153] usb 3-1: Product: USB camera
[439884.851327] gspca: probing 0c45:6142
[439884.856694] sonixj: Sonix chip id: 12
[439884.942767] sonixj: Sensor po2030n
[439884.947226] input: sonixj as 
/devices/pci:00/:00:0b.0/usb3/3-1/input/input4
[439884.968553] gspca: video0 created

The camera works and sometimes the following messages appear in dmesg:

[2992914.118137] gspca: ISOC data error: [3] len=0, status=-84
[3020511.187726] gspca: ISOC data error: [16] len=0, status=-84
[3071235.051448] gspca: ISOC data error: [22] len=0, status=-84
[3178268.392602] gspca: ISOC data error: [11] len=0, status=-84
[3195506.149353] gspca: ISOC data error: [14] len=0, status=-84
[3200576.757068] gspca: ISOC data error: [13] len=0, status=-84
[3242983.446235] gspca: ISOC data error: [20] len=0, status=-84
[3242983.446406] gspca: ISOC data error: [21] len=0, status=-84
[3242983.446526] gspca: ISOC data error: [22] len=0, status=-84
[3242983.446638] gspca: ISOC data error: [23] len=0, status=-84
[3242983.468410] gspca: ISOC data error: [0] len=0, status=-84
[3242983.468578] gspca: ISOC data error: [1] len=0, status=-84
[3242983.468709] gspca: ISOC data error: [2] len=0, status=-84
[3242983.468827] gspca: ISOC data error: [3] len=0, status=-84
...
[3242983.579375] gspca: ISOC data error: [22] len=0, status=-84
[3242983.579375] gspca: ISOC data error: [23] len=0, status=-84
[3242983.588379] gspca: URB error -84, resubmitting
[3242983.591697] usb 3-1: USB disconnect, address 6
[3242983.592489] gspca: ISOC data error: [0] len=0, status=-84
[3242983.592630] gspca: ISOC data error: [1] len=0, status=-84
[3242983.592744] gspca: ISOC data error: [2] len=0, status=-84
[3242983.592856] gspca: ISOC data error: [3] len=0, status=-84
...
[3242983.594935] gspca: ISOC data error: [22] len=0, status=-84
[3242983.595044] gspca: ISOC data error: [23] len=0, status=-84
[3242983.595149] gspca: usb_submit_urb() ret -19
[3242983.602605] gspca: video0 disconnect
[3242983.899568] usb 3-1: new full speed USB device using uhci_hcd and address 7
[3242984.077146] usb 3-1: New USB device found, idVendor=0c45, idProduct=6142
[3242984.077375] usb 3-1: New USB device strings: Mfr=0, Product=1, 
SerialNumber=0
[3242984.077563] usb 3-1: Product: USB camera
[3242984.096020] gspca: probing 0c45:6142
[3242984.117655] sonixj: Sonix chip id: 12
[3242984.221778] sonixj: Sensor po2030n
[3242984.249883] input: sonixj as 
/devices/pci:00/:00:0b.0/usb3/3-1/input/input5
[3242984.258533] gspca: video1 created

At this point the user space application (mencoder) still have the /dev/video0 
device open
but the video0 device is no longer there. Instead the video1 is created.

I already saw similar behaviour in case of suspend-resume cycle, see
Bug 13419 - gspca: /dev/video0 changes to /dev/video1 after suspend
https://bugzilla.kernel.org/show_bug.cgi?id=13419

The error code -84 refers to EILSEQ (Illegal byte sequence) according to 
include/asm-generic/errno.h .
What could be the reason for ISO data error?

I guess the video0 is disconnected as part of error recovery. In this case, 
however
the video1 device is created so the user space application looses the original
video streaming device. Is this how it shall work?

Regards,

Márton Németh


--
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: gspca: video0 becomes video1 after ISOC data error

2011-07-04 Thread Mauro Carvalho Chehab
Em 04-07-2011 17:58, Németh Márton escreveu:
 Hi,
 
 I'm running Debian with Linux 2.6.38-2-486 on a computer. I have a hama 
 AC-150 webcam
 attached to this computer. The webcam works continouosly and I use mencoder 
 to do some
 cropping and transformation and to encode the video stream to a file.
 
 When I plug the device the following appears in the dmesg:
 
 [439884.692090] usb 3-1: new full speed USB device using uhci_hcd and address 
 6
 [439884.841721] usb 3-1: New USB device found, idVendor=0c45, idProduct=6142
 [439884.841958] usb 3-1: New USB device strings: Mfr=0, Product=1, 
 SerialNumber=0
 [439884.842153] usb 3-1: Product: USB camera
 [439884.851327] gspca: probing 0c45:6142
 [439884.856694] sonixj: Sonix chip id: 12
 [439884.942767] sonixj: Sensor po2030n
 [439884.947226] input: sonixj as 
 /devices/pci:00/:00:0b.0/usb3/3-1/input/input4
 [439884.968553] gspca: video0 created
 
 The camera works and sometimes the following messages appear in dmesg:
 
 [2992914.118137] gspca: ISOC data error: [3] len=0, status=-84
 [3020511.187726] gspca: ISOC data error: [16] len=0, status=-84
 [3071235.051448] gspca: ISOC data error: [22] len=0, status=-84
 [3178268.392602] gspca: ISOC data error: [11] len=0, status=-84
 [3195506.149353] gspca: ISOC data error: [14] len=0, status=-84
 [3200576.757068] gspca: ISOC data error: [13] len=0, status=-84
 [3242983.446235] gspca: ISOC data error: [20] len=0, status=-84
 [3242983.446406] gspca: ISOC data error: [21] len=0, status=-84
 [3242983.446526] gspca: ISOC data error: [22] len=0, status=-84
 [3242983.446638] gspca: ISOC data error: [23] len=0, status=-84
 [3242983.468410] gspca: ISOC data error: [0] len=0, status=-84
 [3242983.468578] gspca: ISOC data error: [1] len=0, status=-84
 [3242983.468709] gspca: ISOC data error: [2] len=0, status=-84
 [3242983.468827] gspca: ISOC data error: [3] len=0, status=-84
 ...
 [3242983.579375] gspca: ISOC data error: [22] len=0, status=-84
 [3242983.579375] gspca: ISOC data error: [23] len=0, status=-84
 [3242983.588379] gspca: URB error -84, resubmitting
 [3242983.591697] usb 3-1: USB disconnect, address 6
 [3242983.592489] gspca: ISOC data error: [0] len=0, status=-84
 [3242983.592630] gspca: ISOC data error: [1] len=0, status=-84
 [3242983.592744] gspca: ISOC data error: [2] len=0, status=-84
 [3242983.592856] gspca: ISOC data error: [3] len=0, status=-84
 ...
 [3242983.594935] gspca: ISOC data error: [22] len=0, status=-84
 [3242983.595044] gspca: ISOC data error: [23] len=0, status=-84
 [3242983.595149] gspca: usb_submit_urb() ret -19
 [3242983.602605] gspca: video0 disconnect
 [3242983.899568] usb 3-1: new full speed USB device using uhci_hcd and 
 address 7
 [3242984.077146] usb 3-1: New USB device found, idVendor=0c45, idProduct=6142
 [3242984.077375] usb 3-1: New USB device strings: Mfr=0, Product=1, 
 SerialNumber=0
 [3242984.077563] usb 3-1: Product: USB camera
 [3242984.096020] gspca: probing 0c45:6142
 [3242984.117655] sonixj: Sonix chip id: 12
 [3242984.221778] sonixj: Sensor po2030n
 [3242984.249883] input: sonixj as 
 /devices/pci:00/:00:0b.0/usb3/3-1/input/input5
 [3242984.258533] gspca: video1 created
 
 At this point the user space application (mencoder) still have the 
 /dev/video0 device open
 but the video0 device is no longer there. Instead the video1 is created.
 
 I already saw similar behaviour in case of suspend-resume cycle, see
 Bug 13419 - gspca: /dev/video0 changes to /dev/video1 after suspend
 https://bugzilla.kernel.org/show_bug.cgi?id=13419

In suspend/resume, it seems a driver bug to me.

 
 The error code -84 refers to EILSEQ (Illegal byte sequence) according to 
 include/asm-generic/errno.h .
 What could be the reason for ISO data error?
 
 I guess the video0 is disconnected as part of error recovery. In this case, 
 however
 the video1 device is created so the user space application looses the original
 video streaming device. Is this how it shall work?

It seems a bug that mencoder didn't stopped streaming with EILSEQ. Maybe this 
erros is
not properly propagated?

In any case, if the userspace application keeps a device opened, the Kernel 
needs to get
the next available major/minor, as, otherwise, an OOPS or panic will happen, as 
the kernel
can't free the major/minor while it is in usage.

The alternative for that would be to create an alias, via udev, for example, 
calling it
as /dev/webcam0, and keeping the value permanent, for the same device. This 
way, the name
of the device won't change (but the minor will keep changing). This won't solve 
the
issue, except if the application would close and re-open the devnode, when such 
error occurs.

Cheers,
Mauro
--
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] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset

2011-07-04 Thread Laurent Pinchart
Hi Mauro,

On Monday 04 July 2011 18:09:18 Mauro Carvalho Chehab wrote:

[snip]

 1) PRESET STANDARDS
== =
 
 There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and
 CEA 861.
 
 At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as 60 Hz.
 BT.1120 follows the same logic, as it uses BT.709 as a reference for video
 timings.
 
 The CEA-861-E spec says at item 4, that:

[snip]

 At the same item, the table 2 describes several video parameters for each
 preset, associating the Video Identification Codes (VIC) for each preset.

This might be a bit out of scope, but why aren't we using the VICs as DV 
presets ?

-- 
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: [RFC] DV timings spec fixes at V4L2 API - was: [PATCH 1/8] v4l: add macro for 1080p59_54 preset

2011-07-04 Thread Mauro Carvalho Chehab
Em 04-07-2011 19:47, Laurent Pinchart escreveu:
 Hi Mauro,
 
 On Monday 04 July 2011 18:09:18 Mauro Carvalho Chehab wrote:
 
 [snip]
 
 1) PRESET STANDARDS
== =

 There are 3 specs involved with DV presets: ITU-R BT 709 and BT 1120 and
 CEA 861.

 At ITU-R BT.709, both 60Hz and 60/1.001 Hz are equally called as 60 Hz.
 BT.1120 follows the same logic, as it uses BT.709 as a reference for video
 timings.

 The CEA-861-E spec says at item 4, that:
 
 [snip]
 
 At the same item, the table 2 describes several video parameters for each
 preset, associating the Video Identification Codes (VIC) for each preset.
 
 This might be a bit out of scope, but why aren't we using the VICs as DV 
 presets ?

I had the same question after analyzing the specs ;)

That's said, abstracting from the spec could be a good idea if we have newer
versions of the spec re-defining the VICs.

Maybe the right thing to do would be to rename the presets as:

V4L2_DV_CEA861_VIC_16
V4L2_DV_CEA861_VIC_35_36
...

(or course, preserving the old names with compatibility macros)

Cheers,
Mauro

--
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] dvb_frontend: fix race condition in stopping/starting frontend

2011-07-04 Thread Devin Heitmueller
Attached is a patch which addresses a race condition in the DVB core
related to closing/reopening the DVB frontend device in quick
succession.  This is the reason that devices such as the HVR-1300,
HVR-3000, and HVR-4000 have been failing to scan properly under MythTV
and w_scan.

The gory details of the race are described in the patch.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
dvb_frontend: fix race condition in stopping/starting frontend

From: Devin Heitmueller dheitmuel...@kernellabs.com

There is a race condition exhibited when channel scanners such as w_scan and
MythTV quickly close and then reopen the frontend device node.

Under normal conditions, the behavior is as follows:

1.  Application closes the device node
2.  DVB frontend ioctl calls dvb_frontend_release which sets
fepriv-release_jiffies
3.  DVB frontend thread *eventually* calls dvb_frontend_is_exiting() which
compares fepriv-release_jiffies, and shuts down the thread if timeout has
expired
4.  Thread goes away
5.  Application opens frontend device
6.  DVB frontend ioctl() calls ts_bus_ctrl(1)
7.  DVB frontend ioctl() creates new frontend thread, which calls
dvb_frontend_init(), which has demod driver init() routine setup initial
register state for demod chip.
8.  Tuning request is issued.

The race occurs when the application in step 5 performs the new open() call
before the frontend thread is shutdown.  In this case the ts_bus_ctrl() call
is made, which strobes the RESET pin on the demodulator, but the
dvb_frontend_init() function never gets called because the frontend thread
hasn't gone away yet.  As a result, the initial register config for the demod
is *never* setup, causing subsequent tuning requests to fail.

If there is time between the close and open (enough for the dvb frontend
thread to be torn down), then in that case the new frontend thread is created
and thus the dvb_frontend_init() function does get called.

The fix is to set the flag which forces reinitialization if we did in fact
call ts_bus_ctrl().

This problem has been seen on the HVR-1300, HVR-3000, and HVR-4000, and is
likely occuring on other designs as well where ts_bus_ctrl() actually strobes
the reset pin on the demodulator.

Note that this patch should supercede any patches submitted for the
1300/3000/4000 which remove the code that removes GPIO code in
cx8802_dvb_advise_acquire(), which have been circulating by users for some
time now...

Canonical tracking this issue in Launchpad 439163:

https://bugs.launchpad.net/mythtv/+bug/439163

Thanks to Jon Sayers from Hauppauge and Florent Audebert from Anevia S.A. for
providing hardware to test/debug with.

Signed-off-by: Devin Heitmueller dheitmuel...@kernellabs.com
Cc: Jon Sayers j.say...@hauppauge.co.uk
Cc: Florent Audebert florent.audeb...@anevia.com

diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index bed7bfe..efe9c30 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -1989,6 +1989,14 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
 	if (dvbdev-users == -1  fe-ops.ts_bus_ctrl) {
 		if ((ret = fe-ops.ts_bus_ctrl(fe, 1))  0)
 			goto err0;
+
+		/* If we took control of the bus, we need to force
+		   reinitialization.  This is because many ts_bus_ctrl()
+		   functions strobe the RESET pin on the demod, and if the
+		   frontend thread already exists then the dvb_init() routine
+		   won't get called (which is what usually does initial
+		   register configuration). */
+		fepriv-reinitialise = 1;
 	}
 
 	if ((ret = dvb_generic_open (inode, file))  0)


Re: Bug in HVR1300. Found part of a patch, if reverted

2011-07-04 Thread Devin Heitmueller
On Thu, May 12, 2011 at 10:14 AM, Mike michael.st...@iinet.net.au wrote:
 Hi there

 in the latest kernel (and all those since when the patch was written) this
 patch is still required for the HVR-1300 to work, any chance of it getting
 incorporated?

 thanks
 Mike

Hello Mike,

Please try out the following patch which has been submitted upstream,
which should fix the actual underlying problem (the patch that has
been circulating in Launchpad 439163 doesn't fix the *actual* issue).

https://launchpadlibrarian.net/74557311/frontend_dvb_init.patch

The above patch has been submitted for upstream inclusion, so feedback
from users would be useful.

Thanks,

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
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