Re: Improving ov7670 sensor driver.

2012-09-14 Thread javier Martin
Hi Mauro,
thank you for your interest.

On 13 September 2012 15:00, Mauro Carvalho Chehab mche...@redhat.com wrote:
 Hi Javier,

 I'm not too familiar with soc_camera and ov7670 drivers, so my comments
 reflects my understanding of the question, without taking into account
 drivers specifics.

 Em 13-09-2012 06:48, javier Martin escreveu:
 Hi,
 our new i.MX27 based platform (Visstrim-SM20) uses an ov7675 sensor
 attached to the CSI interface. Apparently, this sensor is fully
 compatible with the old ov7670. For this reason, it seems rather
 sensible that they should share the same driver: ov7670.c
 One of the challenges we have to face is that capture video support
 for our platform is mx2_camera.c, which is a soc-camera host driver;
 while ov7670.c was developed for being used as part of a more complex
 video card.

 Here is the list of current users of ov7670:

 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/gspca/ov519.c
 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/gspca/sn9c20x.c
 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/gspca/vc032x.c
 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/via-camera.c
 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/marvell-ccic/mcam-core.c

 In order to avoid breakages on those drivers, we need to be sure that
 none of the changes will alter the register settings used there.

 (C/C Hans de Goede, as he is the gspca maintainer)


 These are basically the improvements we need to make to this driver in
 order to satisfy our needs:

 1.- Adapt v4l2 controls to the subvevice control framework, with a
 proper ctrl handler, etc...
 2.- Add the possibility to bypass PLL and clkrc preescaler.
 3.- Adjust vstart/vstop in order to remove an horizontal green line.
 4.- Disable pixclk during horizontal blanking.
 5.- min_height, min_width should be respected in try_fmt().
 6.- Pass platform data when used with a soc-camera host driver.
 7.- Add V4L2_CID_POWER_LINE_FREQUENCY ctrl.

 Doing one patch per change helps to review the changes individually.
 I suspect that it will needed to be tested with the above drivers,
 anyway.

 I will try to summarize below why we need to accomplish each of the
 previous tasks and what solution we propose for them:

 1.- Adapt v4l2 controls to the subvevice control framework, with a
 proper ctrl handler, etc...

 Why? Because soc-camera needs to inherit v4l2 subdevice controls in
 order to expose them to user space.
 How? Something like the following, incomplete, patch:

 ---
 @@ -190,6 +196,7 @@ MODULE_PARM_DESC(debug, Debug level (0-1));
  struct ov7670_format_struct;  /* coming later */
  struct ov7670_info {
 struct v4l2_subdev sd;
 +   struct v4l2_ctrl_handler hdl;
 struct ov7670_format_struct *fmt;  /* Current format */
 unsigned char sat;  /* Saturation value */
 int hue;/* Hue value */


 @@ -1480,10 +1518,14 @@ static int ov7670_s_register(struct
 v4l2_subdev *sd, struct v4l2_dbg_register *r

  /* --- 
 */

 +static const struct v4l2_ctrl_ops ov7670_ctrl_ops = {
 +   .s_ctrl = ov7670_s_ctrl,
 +};
 +
  static const struct v4l2_subdev_core_ops ov7670_core_ops = {
 .g_chip_ident = ov7670_g_chip_ident,
 -   .g_ctrl = ov7670_g_ctrl,
 -   .s_ctrl = ov7670_s_ctrl,
 +   .g_ctrl = v4l2_subdev_g_ctrl,
 +   .s_ctrl = v4l2_subdev_s_ctrl,
 .queryctrl = ov7670_queryctrl,
 .reset = ov7670_reset,
 .init = ov7670_init,

 @@ -1551,6 +1600,16 @@ static int ov7670_probe(struct i2c_client *client,
 v4l_info(client, chip found @ 0x%02x (%s)\n,
 client-addr  1, client-adapter-name);

 +   v4l2_ctrl_handler_init(info-hdl, 1);
 +   v4l2_ctrl_new_std(info-hdl, ov7670_ctrl_ops,
 V4L2_CID_VFLIP, 0, 1, 1, 0);
 ...
 ...
 +   sd-ctrl_handler = info-hdl;
 +   if (info-hdl.error) {
 +   v4l2_ctrl_handler_free(info-hdl);
 +   kfree(info);
 +   return info-hdl.error;
 +   }
 +   v4l2_ctrl_handler_setup(info-hdl);
 +
 ---

 Tests are required here, but I don't think this would break anything.

 2.- Add the possibility to bypass PLL and clkrc preescaler.

 Why? The formula to get the desired frame rate in this chip in YUV is
 the following: fps = fpclk / (2 * 510 * 784) This means that for a
 desired fps = 30 we need fpclk = 24MHz. For that reason we have a
 clean 24MHz xvclk input that comes from an oscillator. If we enable
 the PLL it internally transforms the 24MHz in 22MHz and thus fps is
 not 30 but 27. In order to get 30fps we need to bypass the PLL.
 How? Defining a platform flag 'direct_clk' or similar that allows
 xvclk being used directly as the pixel clock.

 As this should be a new platform data, provided that the old behavior
 is to use the old formula, this shouldn't break anything.


 3.- Adjust vstart/vstop in order to remove an horizontal 

Re: [PATCH 1/3] Add a core driver for SI476x MFD

2012-09-14 Thread Hans Verkuil
Hi Andrey!

Thanks for posting this driver. One request for the future: please split this
patch up in smaller pieces: one for each c source for example. That makes it
easier to review.

On Fri September 14 2012 00:40:11 Andrey Smirnov wrote:
 This patch adds a core driver for Silicon Laboratories Si476x series
 of AM/FM tuner chips. The driver as a whole is implemented as an MFD device
 and this patch adds a core portion of it that provides all the necessary
 functionality to the two other drivers that represent radio and audio
 codec subsystems of the chip.
 
 Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
 ---
  drivers/mfd/Kconfig |   14 +
  drivers/mfd/Makefile|3 +
  drivers/mfd/si476x-cmd.c| 1509 
 +++
  drivers/mfd/si476x-i2c.c| 1033 +++
  drivers/mfd/si476x-prop.c   |  477 +
  include/linux/mfd/si476x-core.h |  522 ++
  include/media/si476x.h  |  455 
  7 files changed, 4013 insertions(+)
  create mode 100644 drivers/mfd/si476x-cmd.c
  create mode 100644 drivers/mfd/si476x-i2c.c
  create mode 100644 drivers/mfd/si476x-prop.c
  create mode 100644 include/linux/mfd/si476x-core.h
  create mode 100644 include/media/si476x.h
 
 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index b1a1462..3fab06d 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -895,6 +895,20 @@ config MFD_WL1273_CORE
 driver connects the radio-wl1273 V4L2 module and the wl1273
 audio codec.
  
 +config MFD_SI476X_CORE
 + tristate Support for Silicon Laboratories 4761/64/68 AM/FM radio.
 + depends on I2C
 + select MFD_CORE
 + default n
 + help
 +   This is the core driver for the SI476x series of AM/FM radio. This MFD
 +   driver connects the radio-si476x V4L2 module and the si476x
 +   audio codec.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called si476x-core.
 +
 +
  config MFD_OMAP_USB_HOST
   bool Support OMAP USBHS core driver
   depends on USB_EHCI_HCD_OMAP || USB_OHCI_HCD_OMAP3
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 79dd22d..942257b 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -132,3 +132,6 @@ obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o
  obj-$(CONFIG_MFD_SEC_CORE)   += sec-core.o sec-irq.o
  obj-$(CONFIG_MFD_ANATOP) += anatop-mfd.o
  obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o
 +
 +si476x-core-objs := si476x-cmd.o si476x-prop.o si476x-i2c.o
 +obj-$(CONFIG_MFD_SI476X_CORE)+= si476x-core.o
 diff --git a/drivers/mfd/si476x-cmd.c b/drivers/mfd/si476x-cmd.c
 new file mode 100644
 index 000..defe1f5
 --- /dev/null
 +++ b/drivers/mfd/si476x-cmd.c
 @@ -0,0 +1,1509 @@
 +/*
 + * include/media/si476x-cmd.c -- Subroutines implementing command
 + * protocol of si476x series of chips
 + *
 + * Copyright (C) 2012 Innovative Converged Devices(ICD)
 + *
 + * Author: Andrey Smirnov andrey.smir...@convergeddevices.net
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; version 2 of the License.
 + *
 + * This program is distributed in the hope that it will be useful, but
 + * WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * General Public License for more details.
 + *
 + */
 +#include linux/module.h
 +#include linux/completion.h
 +#include linux/delay.h
 +#include linux/atomic.h
 +#include linux/i2c.h
 +#include linux/device.h
 +#include linux/gpio.h
 +#include linux/videodev2.h
 +
 +#include media/si476x.h
 +#include linux/mfd/si476x-core.h
 +
 +#define msb(x)  ((u8)((u16) x  8))
 +#define lsb(x)  ((u8)((u16) x   0x00FF))
 +
 +
 +
 +#define CMD_POWER_UP 0x01
 +#define CMD_POWER_UP_A10_NRESP   1
 +#define CMD_POWER_UP_A10_NARGS   5
 +
 +#define CMD_POWER_UP_A20_NRESP   1
 +#define CMD_POWER_UP_A20_NARGS   5
 +
 +#define POWER_UP_DELAY_MS110
 +
 +#define CMD_POWER_DOWN   0x11
 +#define CMD_POWER_DOWN_A10_NRESP 1
 +
 +#define CMD_POWER_DOWN_A20_NRESP 1
 +#define CMD_POWER_DOWN_A20_NARGS 1
 +
 +#define CMD_FUNC_INFO0x12
 +#define CMD_FUNC_INFO_NRESP  7
 +
 +#define CMD_SET_PROPERTY 0x13
 +#define CMD_SET_PROPERTY_NARGS   5
 +#define CMD_SET_PROPERTY_NRESP   1
 +
 +#define CMD_GET_PROPERTY 0x14
 +#define CMD_GET_PROPERTY_NARGS   3
 +#define CMD_GET_PROPERTY_NRESP   4

Re: [PATCH 2/3] Add a V4L2 driver for SI476X MFD

2012-09-14 Thread Hans Verkuil
Hi Andrey!

Some generic comments:

sound/i2c/other/tea575x-tuner.c is a good example of how to make an AM/FM tuner
driver. It's used by e.g. drivers/media/radio/radio-shark.c. This went in just
yesterday, so you need to look at the latest staging/for_v3.7 branch of the
media_tree.git repo.

Some main missing pieces here:

- you must use a struct v4l2_device as the top-level struct.
- you must use the control framework to handle controls
- you must use struct v4l2_fh as that gives you V4L2 priority handling and
  control events for free.
- don't use audio inputs to select the freq bands. Instead do what tea575x does:
  implement enum_freq_bands and do the right checks in hw_freq_seek. See the
  documentation for those ioctls in the latest V4L2 spec available from 
linuxtv.org.
- is the RDS format that's returned with read() compliant to the V4L2 spec?
  See: http://linuxtv.org/downloads/v4l-dvb-apis/rds.html
  Note that the v4l-utils repository contains a command line tool rds-ctl to 
test
  rds input.
- run v4l2-compliance for your driver. This is available in the v4l-utils.git 
repo
  (use the master branch) on linuxtv.org. This tool verifies whether your driver
  is fully V4L2 compliant. There should be no errors or warnings. In case of 
doubt
  or if you suspect a bug in the tool, then please contact me and/or the 
mailinglist!

Several of the controls can be dropped when frequency bands are implemented
correctly. There are a few others that probably need to be turned into
standard controls. We can discuss that for the next version of this patch.

On Fri September 14 2012 00:40:12 Andrey Smirnov wrote:
 This commit adds a driver that exposes all the radio related
 functionality of the Si476x series of chips via the V4L2 subsystem.
 
 Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
 ---
  drivers/media/radio/Kconfig|   17 +
  drivers/media/radio/radio-si476x.c | 1307 
 
  2 files changed, 1324 insertions(+)
  create mode 100644 drivers/media/radio/radio-si476x.c
 
 diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
 index 8090b87..3c79d09 100644
 --- a/drivers/media/radio/Kconfig
 +++ b/drivers/media/radio/Kconfig
 @@ -16,6 +16,23 @@ config RADIO_SI470X
   bool Silicon Labs Si470x FM Radio Receiver support
   depends on VIDEO_V4L2
  
 +config RADIO_SI476X
 + tristate Silicon Laboratories Si476x I2C FM Radio
 + depends on I2C  VIDEO_V4L2
 + select MFD_CORE
 + select MFD_SI476X_CORE
 + select SND_SOC_SI476X
 + ---help---
 +   Choose Y here if you have this FM radio chip.
 +
 +   In order to control your radio card, you will need to use programs
 +   that are compatible with the Video For Linux 2 API.  Information on
 +   this API and pointers to v4l2 programs may be found at
 +   file:Documentation/video4linux/API.html.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called radio-si476x.
 +
  source drivers/media/radio/si470x/Kconfig
  
  config USB_MR800
 diff --git a/drivers/media/radio/radio-si476x.c 
 b/drivers/media/radio/radio-si476x.c
 new file mode 100644
 index 000..f313005
 --- /dev/null
 +++ b/drivers/media/radio/radio-si476x.c
 @@ -0,0 +1,1307 @@
 +#include linux/module.h
 +#include linux/delay.h
 +#include linux/interrupt.h
 +#include linux/slab.h
 +#include linux/atomic.h
 +#include media/v4l2-common.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-device.h
 +#include media/v4l2-ioctl.h
 +
 +#include linux/mfd/si476x-core.h
 +
 +#define FM_FREQ_RANGE_LOW   6400
 +#define FM_FREQ_RANGE_HIGH 10800
 +
 +#define AM_FREQ_RANGE_LOW52
 +#define AM_FREQ_RANGE_HIGH 3000
 +
 +#define PWRLINEFLTR (1  8)
 +
 +#define FREQ_MUL (1000 / 625)
 +
 +#define DRIVER_NAME si476x-radio
 +#define DRIVER_CARD SI476x AM/FM Receiver
 +
 +static const char * const deemphasis[] = {
 + 75 us,
 + 50 us,
 +};
 +
 +static const char * const grid_frequency[] = {
 + 50 Hz,
 + 60 Hz,
 +};
 +
 +#define PRIVATE_CTL_IDX(x) (x - V4L2_CID_PRIVATE_BASE)
 +
 +static const struct v4l2_queryctrl si476x_ctrls[] = {
 + /*
 +Tuning parameters
 +'max tune errors' is shared for both AM/FM mode of operation
 + */
 + {
 + .id = SI476X_CID_RSSI_THRESHOLD,
 + .type   = V4L2_CTRL_TYPE_INTEGER,
 + .name   = valid rssi threshold,
 + .minimum= -128,
 + .maximum= 127,
 + .step   = 1,
 + },
 + {
 + .id = SI476X_CID_SNR_THRESHOLD,
 + .type   = V4L2_CTRL_TYPE_INTEGER,
 + .name   = valid snr threshold,
 + .minimum= -128,
 + .maximum= 127,
 + .step   = 1,
 + },
 + {
 + .id = SI476X_CID_MAX_TUNE_ERROR,
 + 

Re: [GIT PULL] ViewCast O820E capture support added

2012-09-14 Thread Hans Verkuil
On Fri September 14 2012 04:09:42 Mauro Carvalho Chehab wrote:
 Em 13-09-2012 21:59, Mauro Carvalho Chehab escreveu:
  Em Thu, 13 Sep 2012 20:23:42 -0300
  Mauro Carvalho Chehab mche...@redhat.com escreveu:
  
  Em 13-09-2012 20:19, Mauro Carvalho Chehab escreveu:
  Em Sat, 18 Aug 2012 11:48:52 -0400
  Steven Toth st...@kernellabs.com escreveu:
 
  Mauro, please read below, a new set of patches I'm submitting for merge.
 
  On Thu, Aug 16, 2012 at 2:49 PM, Hans Verkuil hverk...@xs4all.nl wrote:
  On Thu August 16 2012 19:39:51 Steven Toth wrote:
  So, I've ran v4l2-compliance and it pointed out a few things that 
  I've
  fixed, but it also does a few things that (for some reason) I can't
  seem to catch. One particular test is on (iirc) s_fmt. It attempts to
  set ATSC but by ioctl callback never receives ATSC in the norm/id 
  arg,
  it actually receives 0x0. This feels more like a bug in the test.
  Either way, I have some if (std  ATSC) return -EINVAL, but it still
  appears to fail the test.
 
  Oddly enough. If I set tvnorms to something valid, then compliance
  passes but gstreamer
  fails to run, looks like some kind of confusion about either the
  current established
  norm, or a failure to establish a norm.
 
  For the time being I've set tvnorms to 0 (with a comment) and removed
  current_norm.
 
  Well, this needs to be sorted, because something is clearly amiss.
 
  Agreed. I just can't see what's wrong. I may need your advise /
  eyeballs on this. I'd be willing to provide logs that show gstreamer
  accessing the driver and exiting. It needs fixed, I've tried, I just
  can't see why gstreamer fails.
 
  On the main topic of merge As promised, I spent quite a bit of
  time this week reworking the code based on the feedback. I also
  flattened all of these patches into a single patchset and upgraded to
  the latest re-org tree.
 
  The source notes describe in a little more detail the major changes:
  http://git.kernellabs.com/?p=stoth/media_tree.git;a=commit;h=f295dd63e2f7027e327daad730eb86f2c17e3b2c
 
  Mauro, so, I hereby submit for your review/merge again, the updated
  patchset. *** Please comment. ***
 
  I'll comment patch by patch. Let's hope the ML will get this email. Not 
  sure,
  as it tends to discard big emails like that.
 
  This is the comment of patch 1/4.
 
 
  Patch 2 is trivial. It is obviously OK.
 
  Patch 3 also looked OK on my eyes.
  
  Patch 4 will very likely be discarded by vger server, if everything is
  added there. So, I'll drop the parts that weren't commented.
  
  Anyway:
  
  Subject: [media] vc8x0: Adding support for the ViewCast O820E Capture Card.
  Cc: Linux Media Mailing List linux-media@vger.kernel.org
 
  A dual channel 1920x1080p60 PCIe x4 capture card, two DVI
  inputs capable of capturing DVI/HDMI, Component, Svideo, Composite
  and some VGA resolutions.
  ...
  


  diff --git a/drivers/media/pci/vc8x0/vc8x0-display.c 
  b/drivers/media/pci/vc8x0/vc8x0-display.c
  
  +struct letter_t {
  +  u8 *ptr;
  +  u8 data[8];
  +} charset[] = {
  + /* ' ' */ [0x20] = { 0, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 
  }, },
  + /*  */
  + /*  */
  + /*  */
  + /*  */
  + /*  */
  + /*  */
  + /*  */
  + /*  */
  + /* '!' */ [0x21] = { 0, { 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x04, 0x00 
  }, },
  + /* 0100 */
  + /* 0100 */
  + /* 0100 */
  + /* 0100 */
  + /*  */
  + /*  */
  + /* 0100 */
  + /*  */
  
  Charset No, please! If you really need a charset, take a look at the
  vivi driver. It uses an already-existent Kernel charset. See:
  
  static int __init vivi_init(void)
  {
  const struct font_desc *font = find_font(VGA8x16);
  
  Not sure about the rest of the code here at vc8x0-display.c, but maybe 
  you'll
  find a similar code to it already coded. Where do you use it?

I think all this is just for debugging and should just be removed. It renders
debugging text in the frame.

  diff --git a/drivers/media/pci/vc8x0/vc8x0-video.c 
  b/drivers/media/pci/vc8x0/vc8x0-video.c
 

  +static int vc8x0_video_generate_osd(struct vc8x0_dma_channel *channel, u8 
  *dst)
  +{
  +#if 1
  +   return 0;
  +#else
  +   /* Do some text rendering */
  +   struct vc8x0_format *fmt = channel-ad7441_ctx.detected_fmt;
  +   unsigned char tmp[256];
  +   int ret;
  +
  +   ret = vc8x0_display_render_reset(channel-display_ctx, dst,
  +   channel-fmt-width);
  +   if (ret  0)
  +   return ret;
 
 Hmm... Are you using the *-display.c code for OSD? Not sure if it is
 a good idea to handle it like that.
 
 Hans,
 
 What do you think?
 
 Yet, the code here is commented, but there's a hole driver there in order
 to implement OSD display, just bloating the driver's code... 

I think it can all be removed completely. It's not a real OSD, it just
renders text in a captured frame.

  +static int vc8x0_log_status(struct file *file, 

Re: [PATCHv3 2/9] ir-rx51: Handle signals properly

2012-09-14 Thread Timo Kokkonen
On 09/03/12 15:36, Sean Young wrote:
 On Sun, Sep 02, 2012 at 11:08:20PM +0300, Timo Kokkonen wrote:
 On 09/02/12 22:41, Sakari Ailus wrote:
 On Sun, Sep 02, 2012 at 06:20:27PM +0300, Timo Kokkonen wrote:
 On 09.02 2012 18:06:34, Sakari Ailus wrote:
 Heippa,

 Timo Kokkonen wrote:
 Terve,

 On 09/01/12 20:14, Sakari Ailus wrote:
 Moi,

 On Thu, Aug 30, 2012 at 08:54:24PM +0300, Timo Kokkonen wrote:
 @@ -273,9 +281,18 @@ static ssize_t lirc_rx51_write(struct file *file, 
 const char *buf,

/*
 * Don't return back to the userspace until the transfer has
 -   * finished
 +   * finished. However, we wish to not spend any more than 500ms
 +   * in kernel. No IR code TX should ever take that long.
 +   */
 +  i = wait_event_timeout(lirc_rx51-wqueue, lirc_rx51-wbuf_index 
  0,
 +  HZ / 2);

 Why such an arbitrary timeout? In reality it might not bite the user 
 space
 in practice ever, but is it (and if so, why) really required in the 
 first
 place?

 Well, I can think of two cases:

 1) Something goes wrong. Such before I converted the patch to use the up
 to date PM QoS implementation, the transmitting could take very long
 time because the interrupts were not waking up the MPU. Now that this is
 sorted out only unknown bugs can cause transmitting to hang indefinitely.

 2) User is (intentionally?) doing something wrong. For example by
 feeding in an IR code that has got very long pulses, he could end up
 having the lircd process hung in kernel unkillable for long time. That
 could be avoided quite easily by counting the pulse lengths and
 rejecting any IR codes that are obviously too long. But since I'd like
 to also protect against 1) case, I think this solution works just fine.

 In the end, this is just safety measure that this driver behaves well.

 In that case I think you should use wait_event_interruptible() instead. 

 Well, that's what I had there in the first place. With interruptible
 wait we are left with problem with signals. I was told by Sean Young
 that the lirc API expects the write call to finish only after the IR
 code is transmitted.

 It's not the driver's job to decide what the user can do with the 
 hardware and what not, is it?

 Yeah, policy should be decided by the user space. However, kernel
 should not leave any objvious denial of service holes open
 either. Allowing a process to get stuck unkillable within kernel for
 long time sounds like one to me.
 
 It's not elegant, but this can't be used as a denial of service attack.
 The driver waits for a maximum of a half a second after which signals
 are serviced as normal.
 
 It's interruptible, so the user space can interrupt that wait if it chooses
 so. Besides, if you call this denial of service, then capturing video on
 V4L2 is, too, since others can't use the device in the meantime. :-)


 Well, of course there is no problem if we use interruptible waits. But I
 was told by Sean that the lirc API expects the IR TX to be finished
 always when the write call returns.
 
 This is part of the ABI. The lircd deamon might want to do gap calculation
 if there are large spaces in the IR code being sent. Maybe others can
 enlighten us why such an ABI was choosen.
 
 I guess the assumption is to avoid
 breaking the transmission in the middle in case the process is signaled.
 And that's why we shouldn't use interruptible waits.

 However, if we allow simply breaking the transmitting in case the
 process is signaled any way during the transmission, then the handling
 would be trivial in the driver. That is, if someone for example kills or
 stops the lirc daemon process, then the IR code just wouldn't finish ever.

 Sean, do you have an opinion how this should or is allowed to work?
 
 You want to know when the hardware is done sending the IR. If you return
 EINTR to user space, how would user space know how much IR has been sent, 
 if any?
 
 This ABI is not particularily elegant so there are proposals for a better
 interface which would obsolete the lirc interface. David Hardeman has
 worked on this:
 
 http://patchwork.linuxtv.org/patch/11411/
 

It appears that all modern lirc drivers are now using the rc-core
functionalities to implement the common stuff. When the rx51 lirc driver
was first written, the core was not in place yet. Therefore it is
implementing the file operations in the driver, which other rc drivers
won't do today.

So, I think it would make sense to modify the rx51 driver to use the rc
core functionality. But if there is an ABI change ongoing, I could wait
until you have that done before I start working on the change?

Considering this patch set, I think it makes sense still to apply these
as they improve the existing code base. I'll just squash the one patch
to the misc fixes, as pointed by Sakari, and then re-send the set.

-Timo

 Anyway, we are trying to cover some rare corner cases here, I'm not
 sure how it should work exactly..

 If there was a generic maximum 

Alignment problems: arm_memblock_steal() + dma_declare_coherent_memory()

2012-09-14 Thread javier Martin
Hello,
we use arm_memblock_steal() + dma_declare_coherent_memory() in order
to reserve son contiguous video memory in our platform:
http://git.linuxtv.org/media_tree.git/blob/refs/heads/staging/for_v3.7:/arch/arm/mach-imx/mach-imx27_visstrim_m10.c

We've noticed that some restrictive alignment constraints are being
applied. For example, for coda driver, the following allocations are
made:

coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 557056
bytes, out of 8388608 (vaddr = 0xc600) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 65536
bytes, out of 8388608 (vaddr = 0xc610) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 10240
bytes, out of 8388608 (vaddr = 0xc611) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc620) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc630) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc640) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 589824
bytes, out of 8388608 (vaddr = 0xc650) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 589824
bytes, out of 8388608 (vaddr = 0xc660) PAGE_SHIFT = 0xc
coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
bytes, out of 8388608 (vaddr = 0xc670) PAGE_SHIFT = 0xc

If we take a look at the size of each allocation and the different
vaddr values we find that the alignment is 0x10 = 1MB for values
like 622080 byte size. Why is that?
A lot of memory is being wasted this way and our HW does not have such
1MB alignment requirements.

Regards.
-- 
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: [RFCv2 API PATCH 12/28] v4l2-core: Add new V4L2_CAP_MONOTONIC_TS capability.

2012-09-14 Thread Sakari Ailus
On Thu, Sep 13, 2012 at 10:56:41PM +0200, Hans Verkuil wrote:
 On Thu September 13 2012 22:50:32 Laurent Pinchart wrote:
  Hi Sakari,
  
  On Thursday 13 September 2012 23:38:14 Sakari Ailus wrote:
   On Fri, Sep 07, 2012 at 03:29:12PM +0200, Hans Verkuil wrote:
From: Hans Verkuil hans.verk...@cisco.com

Add a new flag that tells userspace that the monotonic clock is used
for timestamps and update the documentation accordingly.

We decided on this new flag during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---

 Documentation/DocBook/media/v4l/io.xml  |   10 +++---
 Documentation/DocBook/media/v4l/vidioc-dqevent.xml  |3 ++-
 Documentation/DocBook/media/v4l/vidioc-querycap.xml |7 +++
 include/linux/videodev2.h   |1 +
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml
b/Documentation/DocBook/media/v4l/io.xml index 2dc39d8..b680d66 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -582,10 +582,14 @@ applications when an output stream./entry

entrystruct timeval/entry
entrystructfieldtimestamp/structfield/entry
entry/entry

-   entryparaFor input streams this is the
+   entryparaThis is either the

 system time (as returned by the functiongettimeofday()/function

-function) when the first data byte was captured. For output streams
-the data will not be displayed before this time, secondary to the
+function) or a monotonic timestamp (as returned by the
+functionclock_gettime(CLOCK_MONOTONIC, amp;ts)/function function).
+A monotonic timestamp is used if the
constantV4L2_CAP_MONOTONIC_TS/constant +capability is set, otherwise
the system time is used.
+For input streams this is the timestamp when the first data byte was
captured. +For output streams the data will not be displayed before this
time, secondary to the
   I have an alternative proposal.
   
   The type of the desired timestamps depend on the use case, not the driver
   used to capture the buffers. Thus we could also give the choice to the 
   user
   by means of e.g. a control.
  
  Or a buffer flag. I will need something similar to select device-specific 
  timestamps.
  
  However, for wall clock vs. monotonic clock, I don't think there's a reason 
  to 
  let applications decide to use the wall clock. It would be a broken use 
  case. 
  I don't think we should let applications decide in this case.
 
 I agree.

How about the raw monotonic clock then? You can also tell clock_gettime()
what kind of timestamp you're interested in. It's also true monotonic
timestamps are being used elsewhere, so the selection should apply there as
well.

  On the other hand, reporting a timespec instead of a timeval would be a 
  good 
  idea. I'm tempted.
 
 Microsecond precision seems more than sufficient to me for video frames. I see
 no good reason for messing around with the v4l2_buffer struct just to get a
 timespec in.

The extra precision could be confusing for some existing users.

Another thing, however not related to this patch, is that the spec mentions
the timestamp is taken when the first data byte is captured. In practice
many (if not most) drivers produce the timestamp when the buffer is ready.
The reason is that some hardware simply does not produce interrupts at when
the reception of the frame starts. What kind of timestamps should be used in
that case? The frame start event can be used to get information on when the
frame starts.

Regards,

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
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: change path of video drivers

2012-09-14 Thread Prabhakar Lad
From: Lad, Prabhakar prabhakar@ti.com

due to structure change for video drivers, change the
description with correct path.

Signed-off-by: Lad, Prabhakar prabhakar@ti.com
Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Cc: Mauro Carvalho Chehab mche...@infradead.org
Cc: Hans Verkuil hans.verk...@cisco.com
Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
Cc: Sakari Ailus sakari.ai...@iki.fi
Cc: Rob Landley r...@landley.net
---
 Documentation/video4linux/CQcam.txt   |2 +-
 Documentation/video4linux/README.davinci-vpbe |   20 ++--
 Documentation/video4linux/fimc.txt|   16 
 Documentation/video4linux/omap3isp.txt|2 +-
 Documentation/video4linux/v4l2-framework.txt  |2 +-
 Documentation/video4linux/videobuf|2 +-
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/Documentation/video4linux/CQcam.txt 
b/Documentation/video4linux/CQcam.txt
index 6e680fe..0b69e4e 100644
--- a/Documentation/video4linux/CQcam.txt
+++ b/Documentation/video4linux/CQcam.txt
@@ -18,7 +18,7 @@ Table of Contents
 
 1.0 Introduction
 
-  The file ../../drivers/media/video/c-qcam.c is a device driver for
+  The file ../../drivers/media/parport/c-qcam.c is a device driver for
 the Logitech (nee Connectix) parallel port interface color CCD camera.
 This is a fairly inexpensive device for capturing images.  Logitech
 does not currently provide information for developers, but many people
diff --git a/Documentation/video4linux/README.davinci-vpbe 
b/Documentation/video4linux/README.davinci-vpbe
index 7a460b0..dc9a297 100644
--- a/Documentation/video4linux/README.davinci-vpbe
+++ b/Documentation/video4linux/README.davinci-vpbe
@@ -5,22 +5,22 @@
  File partitioning
  -
  V4L2 display device driver
- drivers/media/video/davinci/vpbe_display.c
- drivers/media/video/davinci/vpbe_display.h
+ drivers/media/platform/davinci/vpbe_display.c
+ drivers/media/platform/davinci/vpbe_display.h
 
  VPBE display controller
- drivers/media/video/davinci/vpbe.c
- drivers/media/video/davinci/vpbe.h
+ drivers/media/platform/davinci/vpbe.c
+ drivers/media/platform/davinci/vpbe.h
 
  VPBE venc sub device driver
- drivers/media/video/davinci/vpbe_venc.c
- drivers/media/video/davinci/vpbe_venc.h
- drivers/media/video/davinci/vpbe_venc_regs.h
+ drivers/media/platform/davinci/vpbe_venc.c
+ drivers/media/platform/davinci/vpbe_venc.h
+ drivers/media/platform/davinci/vpbe_venc_regs.h
 
  VPBE osd driver
- drivers/media/video/davinci/vpbe_osd.c
- drivers/media/video/davinci/vpbe_osd.h
- drivers/media/video/davinci/vpbe_osd_regs.h
+ drivers/media/platform/davinci/vpbe_osd.c
+ drivers/media/platform/davinci/vpbe_osd.h
+ drivers/media/platform/davinci/vpbe_osd_regs.h
 
  Functional partitioning
  ---
diff --git a/Documentation/video4linux/fimc.txt 
b/Documentation/video4linux/fimc.txt
index eb04970..fd02d9a 100644
--- a/Documentation/video4linux/fimc.txt
+++ b/Documentation/video4linux/fimc.txt
@@ -10,7 +10,7 @@ data from LCD controller (FIMD) through the SoC internal 
writeback data
 path.  There are multiple FIMC instances in the SoCs (up to 4), having
 slightly different capabilities, like pixel alignment constraints, rotator
 availability, LCD writeback support, etc. The driver is located at
-drivers/media/video/s5p-fimc directory.
+drivers/media/platform/s5p-fimc directory.
 
 1. Supported SoCs
 =
@@ -36,21 +36,21 @@ Not currently supported:
 =
 
 - media device driver
-  drivers/media/video/s5p-fimc/fimc-mdevice.[ch]
+  drivers/media/platform/s5p-fimc/fimc-mdevice.[ch]
 
  - camera capture video device driver
-  drivers/media/video/s5p-fimc/fimc-capture.c
+  drivers/media/platform/s5p-fimc/fimc-capture.c
 
  - MIPI-CSI2 receiver subdev
-  drivers/media/video/s5p-fimc/mipi-csis.[ch]
+  drivers/media/platform/s5p-fimc/mipi-csis.[ch]
 
  - video post-processor (mem-to-mem)
-  drivers/media/video/s5p-fimc/fimc-core.c
+  drivers/media/platform/s5p-fimc/fimc-core.c
 
  - common files
-  drivers/media/video/s5p-fimc/fimc-core.h
-  drivers/media/video/s5p-fimc/fimc-reg.h
-  drivers/media/video/s5p-fimc/regs-fimc.h
+  drivers/media/platform/s5p-fimc/fimc-core.h
+  drivers/media/platform/s5p-fimc/fimc-reg.h
+  drivers/media/platform/s5p-fimc/regs-fimc.h
 
 4. User space interfaces
 
diff --git a/Documentation/video4linux/omap3isp.txt 
b/Documentation/video4linux/omap3isp.txt
index 5dd1439..b9a9f83 100644
--- a/Documentation/video4linux/omap3isp.txt
+++ b/Documentation/video4linux/omap3isp.txt
@@ -12,7 +12,7 @@ Introduction
 
 
 This file documents the Texas Instruments OMAP 3 Image Signal Processor (ISP)
-driver located under drivers/media/video/omap3isp. The original driver was
+driver located under 

Re: [RFCv2 API PATCH 12/28] v4l2-core: Add new V4L2_CAP_MONOTONIC_TS capability.

2012-09-14 Thread Hans Verkuil
On Fri 14 September 2012 11:02:22 Sakari Ailus wrote:
 On Thu, Sep 13, 2012 at 10:56:41PM +0200, Hans Verkuil wrote:
  On Thu September 13 2012 22:50:32 Laurent Pinchart wrote:
   Hi Sakari,
   
   On Thursday 13 September 2012 23:38:14 Sakari Ailus wrote:
On Fri, Sep 07, 2012 at 03:29:12PM +0200, Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 Add a new flag that tells userspace that the monotonic clock is used
 for timestamps and update the documentation accordingly.
 
 We decided on this new flag during the 2012 Media Workshop.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
 
  Documentation/DocBook/media/v4l/io.xml  |   10 +++---
  Documentation/DocBook/media/v4l/vidioc-dqevent.xml  |3 ++-
  Documentation/DocBook/media/v4l/vidioc-querycap.xml |7 +++
  include/linux/videodev2.h   |1 +
  4 files changed, 17 insertions(+), 4 deletions(-)
 
 diff --git a/Documentation/DocBook/media/v4l/io.xml
 b/Documentation/DocBook/media/v4l/io.xml index 2dc39d8..b680d66 100644
 --- a/Documentation/DocBook/media/v4l/io.xml
 +++ b/Documentation/DocBook/media/v4l/io.xml
 @@ -582,10 +582,14 @@ applications when an output stream./entry
 
   entrystruct timeval/entry
   entrystructfieldtimestamp/structfield/entry
   entry/entry
 
 - entryparaFor input streams this is the
 + entryparaThis is either the
 
  system time (as returned by the functiongettimeofday()/function
 
 -function) when the first data byte was captured. For output streams
 -the data will not be displayed before this time, secondary to the
 +function) or a monotonic timestamp (as returned by the
 +functionclock_gettime(CLOCK_MONOTONIC, amp;ts)/function 
 function).
 +A monotonic timestamp is used if the
 constantV4L2_CAP_MONOTONIC_TS/constant +capability is set, 
 otherwise
 the system time is used.
 +For input streams this is the timestamp when the first data byte was
 captured. +For output streams the data will not be displayed before 
 this
 time, secondary to the
I have an alternative proposal.

The type of the desired timestamps depend on the use case, not the 
driver
used to capture the buffers. Thus we could also give the choice to the 
user
by means of e.g. a control.
   
   Or a buffer flag. I will need something similar to select device-specific 
   timestamps.
   
   However, for wall clock vs. monotonic clock, I don't think there's a 
   reason to 
   let applications decide to use the wall clock. It would be a broken use 
   case. 
   I don't think we should let applications decide in this case.
  
  I agree.
 
 How about the raw monotonic clock then? You can also tell clock_gettime()
 what kind of timestamp you're interested in. It's also true monotonic
 timestamps are being used elsewhere, so the selection should apply there as
 well.

ALSA only has wallclock time and monotonic clock, not raw monotonic.

The important thing right now is that apps can tell that a driver uses a
monotonic clock. In the future we might want to refine that, but such efforts
should be done together with ALSA.

In other words, let's not add stuff that does not have any users.

Regards,

Hans

 
   On the other hand, reporting a timespec instead of a timeval would be a 
   good 
   idea. I'm tempted.
  
  Microsecond precision seems more than sufficient to me for video frames. I 
  see
  no good reason for messing around with the v4l2_buffer struct just to get a
  timespec in.
 
 The extra precision could be confusing for some existing users.
 
 Another thing, however not related to this patch, is that the spec mentions
 the timestamp is taken when the first data byte is captured. In practice
 many (if not most) drivers produce the timestamp when the buffer is ready.
 The reason is that some hardware simply does not produce interrupts at when
 the reception of the frame starts. What kind of timestamps should be used in
 that case? The frame start event can be used to get information on when the
 frame starts.
 
 Regards,
 
 
--
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] nommu: remap_pfn_range: fix addr parameter check

2012-09-14 Thread Scott Jiang
 Yes, the MMU version of remap_pfn_range() does permit non-page-aligned
 `addr' (at least, if the userspace maaping is a non-COW one).  But I
 suspect that was an implementation accident - it is a nonsensical thing
 to do, isn't it?  The MMU cannot map a bunch of kernel pages onto a
 non-page-aligned userspace address.

 So I'm thinking that we should declare ((addr  ~PAGE_MASK) != 0) to be
 a caller bug, and fix up this regrettably unidentified v4l driver?

I agree. This should be fixed in videobuf.

Hi sharma, what's your kernel version? It seems videobuf2 already
fixed this bug in 3.5.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] s5p-mfc: Remove unreachable code

2012-09-14 Thread Sachin Kamat
Code after return statement never gets executed.
Hence can be deleted.

Signed-off-by: Sachin Kamat sachin.ka...@linaro.org
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c |   21 +
 1 files changed, 1 insertions(+), 20 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index e3e616d..56876be 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1144,30 +1144,11 @@ static int s5p_mfc_suspend(struct device *dev)
 {
struct platform_device *pdev = to_platform_device(dev);
struct s5p_mfc_dev *m_dev = platform_get_drvdata(pdev);
-   int ret;
 
if (m_dev-num_inst == 0)
return 0;
-   return s5p_mfc_sleep(m_dev);
-   if (test_and_set_bit(0, m_dev-enter_suspend) != 0) {
-   mfc_err(Error: going to suspend for a second time\n);
-   return -EIO;
-   }
 
-   /* Check if we're processing then wait if it necessary. */
-   while (test_and_set_bit(0, m_dev-hw_lock) != 0) {
-   /* Try and lock the HW */
-   /* Wait on the interrupt waitqueue */
-   ret = wait_event_interruptible_timeout(m_dev-queue,
-   m_dev-int_cond || 
m_dev-ctx[m_dev-curr_ctx]-int_cond,
-   msecs_to_jiffies(MFC_INT_TIMEOUT));
-
-   if (ret == 0) {
-   mfc_err(Waiting for hardware to finish timed out\n);
-   return -EIO;
-   }
-   }
-   return 0;
+   return s5p_mfc_sleep(m_dev);
 }
 
 static int s5p_mfc_resume(struct device *dev)
-- 
1.7.4.1

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


Re: Alignment problems: arm_memblock_steal() + dma_declare_coherent_memory()

2012-09-14 Thread Russell King - ARM Linux
On Fri, Sep 14, 2012 at 10:49:27AM +0200, javier Martin wrote:
 Hello,
 we use arm_memblock_steal() + dma_declare_coherent_memory() in order
 to reserve son contiguous video memory in our platform:
 http://git.linuxtv.org/media_tree.git/blob/refs/heads/staging/for_v3.7:/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
 
 We've noticed that some restrictive alignment constraints are being
 applied. For example, for coda driver, the following allocations are
 made:
 
 coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 557056
 bytes, out of 8388608 (vaddr = 0xc600) PAGE_SHIFT = 0xc
 coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 65536
 bytes, out of 8388608 (vaddr = 0xc610) PAGE_SHIFT = 0xc
 coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 10240
 bytes, out of 8388608 (vaddr = 0xc611) PAGE_SHIFT = 0xc
 coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
 bytes, out of 8388608 (vaddr = 0xc620) PAGE_SHIFT = 0xc
 coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
 bytes, out of 8388608 (vaddr = 0xc630) PAGE_SHIFT = 0xc
 coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
 bytes, out of 8388608 (vaddr = 0xc640) PAGE_SHIFT = 0xc
 coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 589824
 bytes, out of 8388608 (vaddr = 0xc650) PAGE_SHIFT = 0xc
 coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 589824
 bytes, out of 8388608 (vaddr = 0xc660) PAGE_SHIFT = 0xc
 coda coda-imx27.0: dma_alloc_from_coherent: try to allocate 622080
 bytes, out of 8388608 (vaddr = 0xc670) PAGE_SHIFT = 0xc
 
 If we take a look at the size of each allocation and the different
 vaddr values we find that the alignment is 0x10 = 1MB for values
 like 622080 byte size. Why is that?

Have you thought about get_order() on the allocation size, and what the
resulting order will be?  I'm sure if you could come up with a better
allocation algorithm for this which doesn't lead to too much fragmentation
(or convert it to use the pool infrastructure)...

BTW, your question has nothing to do with arm_memblock_steal().
--
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 v2 0/6] ds3000 improvements

2012-09-14 Thread Rémi Cardona
Hi all,

Here is an updated and more complete patch series for ds3000. I've
done my testing on top of kernel 3.5.2 and things look ok so far.

Reviews and comments are again more than welcome.

Cheers,

Rémi Cardona

-- 
SmartJog | T: +33 1 5868 6229
27 Blvd Hippolyte Marquès, 94200 Ivry-sur-Seine, France
www.smartjog.com | a TDF Group company

--
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/6] [media] ds3000: remove useless 'locking'

2012-09-14 Thread Rémi Cardona
Since b9bf2eafaad9c1ef02fb3db38c74568be601a43a, the function
ds3000_firmware_ondemand() is called only once during init. This
locking scheme may have been useful when the firmware was loaded at
each tune.

Furthermore, it looks like this 'lock' was put in to prevent concurrent
access (and not recursion as the comments suggest). However, this open-
coded mechanism is anything but race-free and should have used a proper
mutex.

Signed-off-by: Rémi Cardona remi.card...@smartjog.com
---
 drivers/media/dvb/frontends/ds3000.c |9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/media/dvb/frontends/ds3000.c 
b/drivers/media/dvb/frontends/ds3000.c
index 46874c7..474f26e 100644
--- a/drivers/media/dvb/frontends/ds3000.c
+++ b/drivers/media/dvb/frontends/ds3000.c
@@ -233,7 +233,6 @@ struct ds3000_state {
struct i2c_adapter *i2c;
const struct ds3000_config *config;
struct dvb_frontend frontend;
-   u8 skip_fw_load;
/* previous uncorrected block counter for DVB-S2 */
u16 prevUCBS2;
 };
@@ -395,8 +394,6 @@ static int ds3000_firmware_ondemand(struct dvb_frontend *fe)
if (ds3000_readreg(state, 0xb2) = 0)
return ret;
 
-   if (state-skip_fw_load)
-   return 0;
/* Load firmware */
/* request the firmware, this will block until someone uploads it */
printk(KERN_INFO %s: Waiting for firmware upload (%s)...\n, __func__,
@@ -410,9 +407,6 @@ static int ds3000_firmware_ondemand(struct dvb_frontend *fe)
return ret;
}
 
-   /* Make sure we don't recurse back through here during loading */
-   state-skip_fw_load = 1;
-
ret = ds3000_load_firmware(fe, fw);
if (ret)
printk(%s: Writing firmware to device failed\n, __func__);
@@ -422,9 +416,6 @@ static int ds3000_firmware_ondemand(struct dvb_frontend *fe)
dprintk(%s: Firmware upload %s\n, __func__,
ret == 0 ? complete : failed);
 
-   /* Ensure firmware is always loaded if required */
-   state-skip_fw_load = 0;
-
return ret;
 }
 
-- 
1.7.10.4

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


[PATCH 4/6] [media] ds3000: bail out early on i2c failures during firmware load

2012-09-14 Thread Rémi Cardona
 - if kmalloc() returns NULL, we can return immediately without trying
   to kfree() a NULL pointer.
 - if i2c_transfer() fails, error out immediately instead of trying to
   upload the remaining bytes of the firmware.
 - the error code is then properly propagated down to ds3000_initfe().

Signed-off-by: Rémi Cardona remi.card...@smartjog.com
---
 drivers/media/dvb/frontends/ds3000.c |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb/frontends/ds3000.c 
b/drivers/media/dvb/frontends/ds3000.c
index 675..162faaf 100644
--- a/drivers/media/dvb/frontends/ds3000.c
+++ b/drivers/media/dvb/frontends/ds3000.c
@@ -280,15 +280,14 @@ static int ds3000_tuner_writereg(struct ds3000_state 
*state, int reg, int data)
 static int ds3000_writeFW(struct ds3000_state *state, int reg,
const u8 *data, u16 len)
 {
-   int i, ret = -EREMOTEIO;
+   int i, ret = 0;
struct i2c_msg msg;
u8 *buf;
 
buf = kmalloc(33, GFP_KERNEL);
if (buf == NULL) {
printk(KERN_ERR Unable to kmalloc\n);
-   ret = -ENOMEM;
-   goto error;
+   return -ENOMEM;
}
 
*(buf) = reg;
@@ -308,8 +307,10 @@ static int ds3000_writeFW(struct ds3000_state *state, int 
reg,
printk(KERN_ERR %s: write error(err == %i, 
reg == 0x%02x\n, __func__, ret, reg);
ret = -EREMOTEIO;
+   goto error;
}
}
+   ret = 0;
 
 error:
kfree(buf);
@@ -426,6 +427,7 @@ static int ds3000_load_firmware(struct dvb_frontend *fe,
const struct firmware *fw)
 {
struct ds3000_state *state = fe-demodulator_priv;
+   int ret = 0;
 
dprintk(%s\n, __func__);
dprintk(Firmware is %zu bytes (%02x %02x .. %02x %02x)\n,
@@ -438,10 +440,10 @@ static int ds3000_load_firmware(struct dvb_frontend *fe,
/* Begin the firmware load process */
ds3000_writereg(state, 0xb2, 0x01);
/* write the entire firmware */
-   ds3000_writeFW(state, 0xb0, fw-data, fw-size);
+   ret = ds3000_writeFW(state, 0xb0, fw-data, fw-size);
ds3000_writereg(state, 0xb2, 0x00);
 
-   return 0;
+   return ret;
 }
 
 static int ds3000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t 
voltage)
-- 
1.7.10.4

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


[PATCH 1/6] [media] ds3000: Declare MODULE_FIRMWARE usage

2012-09-14 Thread Rémi Cardona
Signed-off-by: Rémi Cardona remi.card...@smartjog.com
---
 drivers/media/dvb/frontends/ds3000.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/dvb/frontends/ds3000.c 
b/drivers/media/dvb/frontends/ds3000.c
index 4c8ac26..46874c7 100644
--- a/drivers/media/dvb/frontends/ds3000.c
+++ b/drivers/media/dvb/frontends/ds3000.c
@@ -1310,3 +1310,4 @@ MODULE_DESCRIPTION(DVB Frontend module for Montage 
Technology 
DS3000/TS2020 hardware);
 MODULE_AUTHOR(Konstantin Dimitrov);
 MODULE_LICENSE(GPL);
+MODULE_FIRMWARE(DS3000_DEFAULT_FIRMWARE);
-- 
1.7.10.4

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


[PATCH 6/6] [media] ds3000: add module parameter to force firmware upload

2012-09-14 Thread Rémi Cardona
Signed-off-by: Rémi Cardona remi.card...@smartjog.com
---
 drivers/media/dvb/frontends/ds3000.c |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb/frontends/ds3000.c 
b/drivers/media/dvb/frontends/ds3000.c
index 970963c..3e0e9de 100644
--- a/drivers/media/dvb/frontends/ds3000.c
+++ b/drivers/media/dvb/frontends/ds3000.c
@@ -30,6 +30,7 @@
 #include ds3000.h
 
 static int debug;
+static int force_fw_upload;
 
 #define dprintk(args...) \
do { \
@@ -396,10 +397,13 @@ static int ds3000_firmware_ondemand(struct dvb_frontend 
*fe)
dprintk(%s()\n, __func__);
 
ret = ds3000_readreg(state, 0xb2);
-   if (ret == 0) {
+   if (ret == 0  force_fw_upload == 0) {
printk(KERN_INFO %s: Firmware already uploaded, skipping\n,
__func__);
return ret;
+   } else if (ret == 0  force_fw_upload) {
+   printk(KERN_INFO %s: Firmware already uploaded, 
+   forcing upload\n, __func__);
} else if (ret  0) {
return ret;
}
@@ -1308,6 +1312,9 @@ static struct dvb_frontend_ops ds3000_ops = {
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, Activates frontend debugging (default:0));
 
+module_param(force_fw_upload, int, 0644);
+MODULE_PARM_DESC(force_fw_upload, Force firmware upload (default:0));
+
 MODULE_DESCRIPTION(DVB Frontend module for Montage Technology 
DS3000/TS2020 hardware);
 MODULE_AUTHOR(Konstantin Dimitrov);
-- 
1.7.10.4

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


[PATCH 5/6] [media] ds3000: properly report firmware probing issues

2012-09-14 Thread Rémi Cardona
ds3000_readreg() returns negative values in case of i2c failures. The
old code would simply return 0 when failing to read the 0xb2 register,
misleading ds3000_initfe() into believing that the firmware had been
correctly loaded.

Also print out a message if the chip says a firmware is already loaded.
This should make it more obvious if the chip is in a weird state.

Signed-off-by: Rémi Cardona remi.card...@smartjog.com
---
 drivers/media/dvb/frontends/ds3000.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb/frontends/ds3000.c 
b/drivers/media/dvb/frontends/ds3000.c
index 162faaf..970963c 100644
--- a/drivers/media/dvb/frontends/ds3000.c
+++ b/drivers/media/dvb/frontends/ds3000.c
@@ -395,8 +395,14 @@ static int ds3000_firmware_ondemand(struct dvb_frontend 
*fe)
 
dprintk(%s()\n, __func__);
 
-   if (ds3000_readreg(state, 0xb2) = 0)
+   ret = ds3000_readreg(state, 0xb2);
+   if (ret == 0) {
+   printk(KERN_INFO %s: Firmware already uploaded, skipping\n,
+   __func__);
return ret;
+   } else if (ret  0) {
+   return ret;
+   }
 
/* Load firmware */
/* request the firmware, this will block until someone uploads it */
-- 
1.7.10.4

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


[PATCH 3/6] [media] ds3000: properly report register read errors

2012-09-14 Thread Rémi Cardona
This brings both ds3000_readreg() and ds3000_tuner_readreg() in line
with ds3000_writereg() and ds3000_tuner_writereg() respectively.

Signed-off-by: Rémi Cardona remi.card...@smartjog.com
---
 drivers/media/dvb/frontends/ds3000.c |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb/frontends/ds3000.c 
b/drivers/media/dvb/frontends/ds3000.c
index 474f26e..675 100644
--- a/drivers/media/dvb/frontends/ds3000.c
+++ b/drivers/media/dvb/frontends/ds3000.c
@@ -340,7 +340,7 @@ static int ds3000_readreg(struct ds3000_state *state, u8 
reg)
 
if (ret != 2) {
printk(KERN_ERR %s: reg=0x%x(error=%d)\n, __func__, reg, ret);
-   return ret;
+   return -EREMOTEIO;
}
 
dprintk(%s: read reg 0x%02x, value 0x%02x\n, __func__, reg, b1[0]);
@@ -367,12 +367,15 @@ static int ds3000_tuner_readreg(struct ds3000_state 
*state, u8 reg)
}
};
 
-   ds3000_writereg(state, 0x03, 0x12);
-   ret = i2c_transfer(state-i2c, msg, 2);
+   ret = ds3000_writereg(state, 0x03, 0x12);
+   if (ret  0) {
+   return -EREMOTEIO;
+   }
 
+   ret = i2c_transfer(state-i2c, msg, 2);
if (ret != 2) {
printk(KERN_ERR %s: reg=0x%x(error=%d)\n, __func__, reg, ret);
-   return ret;
+   return -EREMOTEIO;
}
 
dprintk(%s: read reg 0x%02x, value 0x%02x\n, __func__, reg, b1[0]);
-- 
1.7.10.4

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


RE: [PATCH] nommu: remap_pfn_range: fix addr parameter check

2012-09-14 Thread Bhupesh SHARMA
 -Original Message-
 From: Scott Jiang [mailto:scott.jiang.li...@gmail.com]
 Sent: Friday, September 14, 2012 2:53 PM
 To: Andrew Morton
 Cc: Bob Liu; linux...@kvack.org; Bhupesh SHARMA;
 laurent.pinch...@ideasonboard.com; uclinux-dist-
 de...@blackfin.uclinux.org; linux-media@vger.kernel.org;
 dhowe...@redhat.com; ge...@linux-m68k.org; g...@uclinux.org;
 sta...@kernel.org; gre...@linuxfoundation.org; Hugh Dickins
 Subject: Re: [PATCH] nommu: remap_pfn_range: fix addr parameter check
 
  Yes, the MMU version of remap_pfn_range() does permit non-page-
 aligned
  `addr' (at least, if the userspace maaping is a non-COW one).  But I
  suspect that was an implementation accident - it is a nonsensical
  thing to do, isn't it?  The MMU cannot map a bunch of kernel pages
  onto a non-page-aligned userspace address.
 
  So I'm thinking that we should declare ((addr  ~PAGE_MASK) != 0) to
  be a caller bug, and fix up this regrettably unidentified v4l driver?
 
 I agree. This should be fixed in videobuf.
 
 Hi sharma, what's your kernel version? It seems videobuf2 already fixed this
 bug in 3.5.

Hi Scott,

I was using 3.3 linux kernel. I will again check if videobuf2 in 3.5 has 
already fixed this issue.

Regards,
Bhupesh


--
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] nommu: remap_pfn_range: fix addr parameter check

2012-09-14 Thread Bhupesh SHARMA
 -Original Message-
 From: Bhupesh SHARMA
 Sent: Friday, September 14, 2012 3:45 PM
 To: 'Scott Jiang'; Andrew Morton
 Cc: Bob Liu; linux...@kvack.org; laurent.pinch...@ideasonboard.com;
 uclinux-dist-de...@blackfin.uclinux.org; linux-media@vger.kernel.org;
 dhowe...@redhat.com; ge...@linux-m68k.org; g...@uclinux.org;
 sta...@kernel.org; gre...@linuxfoundation.org; Hugh Dickins
 Subject: RE: [PATCH] nommu: remap_pfn_range: fix addr parameter check
 
  -Original Message-
  From: Scott Jiang [mailto:scott.jiang.li...@gmail.com]
  Sent: Friday, September 14, 2012 2:53 PM
  To: Andrew Morton
  Cc: Bob Liu; linux...@kvack.org; Bhupesh SHARMA;
  laurent.pinch...@ideasonboard.com; uclinux-dist-
  de...@blackfin.uclinux.org; linux-media@vger.kernel.org;
  dhowe...@redhat.com; ge...@linux-m68k.org; g...@uclinux.org;
  sta...@kernel.org; gre...@linuxfoundation.org; Hugh Dickins
  Subject: Re: [PATCH] nommu: remap_pfn_range: fix addr parameter check
 
   Yes, the MMU version of remap_pfn_range() does permit non-page-
  aligned
   `addr' (at least, if the userspace maaping is a non-COW one).  But I
   suspect that was an implementation accident - it is a nonsensical
   thing to do, isn't it?  The MMU cannot map a bunch of kernel pages
   onto a non-page-aligned userspace address.
  
   So I'm thinking that we should declare ((addr  ~PAGE_MASK) != 0) to
   be a caller bug, and fix up this regrettably unidentified v4l driver?
 
  I agree. This should be fixed in videobuf.
 
  Hi sharma, what's your kernel version? It seems videobuf2 already
  fixed this bug in 3.5.
 

[snip..]

 
 I was using 3.3 linux kernel. I will again check if videobuf2 in 3.5 has 
 already
 fixed this issue.

[snip..]

Ok I just checked the vb2_dma_contig allocator and it has no major changes from 
my version,
http://lxr.linux.no/linux+v3.5.3/drivers/media/video/videobuf2-dma-contig.c#L37

So, I am not sure if this issue has been fixed in the videobuf2 (or if any 
patch is in the pipeline
which fixes the issue).

BTW I paste my original mail on the subject below to help everyone understand 
the complete setup
and the issue I faced.

Regards,
Bhupesh

-
Hi,

I have been trying recently to make a usb-based-webcam device to work with 
Linux. The entire scheme is a bit complex:

UVC gadget --User Pointer-- User-Space Daemon -- MMAP -- V4L2 capture 
device.

The UVC gadget is internally a v4l2 based device supporting VB2_VMALLOC 
operations, whereas the V4L2 capture device supports VB2_DMA_CONTIG operations.

The application (user-space daemon), is responsible for getting memory 
allocated from the V4L2 capture device via REQBUF calls. The V4L2 capture side 
exposes a
 MMAP IO method, whereas the UVC gadget can get a USERPTR to the buffer filled 
with video data from the V4L2 capture device and then send the same on a USB 
bus.

This scheme works absolutely fine on an architecture having a MMU, but when I 
try the same on a NOMMU arch, I see MMAP calls from the user-space daemon 
failing.

I have implemented a .get_unmapped_area callback in my V4L2 capture driver 
using the blackfin video capture driver as a reference (see [1]).

I make a MMAP call from the user-space application in a sequence like this 
(pretty similar to the standard capture.c example, see[2]):

static void init_mmap (void)
{
struct v4l2_requestbuffers req;

CLEAR (req);

req.count   = 4;
req.type= V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory  = V4L2_MEMORY_MMAP;

if (-1 == xioctl (fd, VIDIOC_REQBUFS, req)) 
{
if (EINVAL == errno) 
{
fprintf (stderr, %s does not support memory 
mapping\n, dev_name);
exit (EXIT_FAILURE);
} 
else 
{
errno_exit (VIDIOC_REQBUFS);
}
}

if (req.count  2) 
{
fprintf (stderr, Insufficient buffer memory on %s\n,dev_name);
exit (EXIT_FAILURE);
}

buffers = (buffer*) calloc (req.count, sizeof (*buffers));

if (!buffers) 
{
fprintf (stderr, Out of memory\n);
exit (EXIT_FAILURE);
}

for (n_buffers = 0; n_buffers  req.count; ++n_buffers) 
{
struct v4l2_buffer buf;

CLEAR (buf);

buf.type= V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory  = V4L2_MEMORY_MMAP;
buf.index   = n_buffers;

if (-1 == xioctl (fd, VIDIOC_QUERYBUF, buf))
errno_exit (VIDIOC_QUERYBUF);

buffers[n_buffers].length = buf.length;
buffers[n_buffers].start =
mmap (NULL /* start anywhere */,
buf.length,

[RFCv3 API PATCH 00/31] Full series of API fixes from the 2012 Media Workshop

2012-09-14 Thread Hans Verkuil
Hi all,

This is the full patch series containing API fixes as discussed during the
2012 Media Workshop.

Regarding the 'make ioctl const' patches: I've only done the easy ones in
this patch series. The remaining write-only ioctls are used much more widely,
so changing those will happen later.

The last few patches that enhance the core code with more stringent tests
against what ioctls can be called for which types of device node will need
reviewing. I have tested it exhaustively with ivtv (which is one of the
most complex drivers, and the only one that has exotic devices like VBI
out).

To use v4l2-compliance with ivtv I also needed to make a few other fixes
elsewhere. The tree with both this patch series and the addition ivtv fixes
can be found here:

http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/ivtv

I have also tested this patch series (actually a slightly older version)
with em28xx. That driver needed a lot of changes to get it to pass the
v4l2-compliance tests. Those can be found here:

http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/em28xx

Changes since RFCv2:

- Rebased to the latest v3.7.
- Fixed some reported typos
- bus_info now requires platform: as prefix for platform devices.
  (patch 05/31)
- Updated vivi and mem2mem_testdev accordingly. (06/31)
- Add feature removal for V4L2_(IN|OUT)_CAP_CUSTOM_TIMINGS. (13/31)
- More improvements to common.xml (patch 14/31): there was a lot there
  that made no sense. I'm sure there is a lot more that can be cleaned up
  in the text, but that's a project in itself.
- Improved the core handling of ENUMSTD and G_PARM for devices where some
  inputs are SDTV and others HDTV (tvnorms will be 0 if the HDTV input is
  the current input). (11/31)
- Extended patch 10/31 to the ENUM functions: those too can return -ENODATA.
- Needed to adapt radio-tea5777.c to the new vidioc_s_freq_hw_seek const
  argument (patch 21/31).

I had hoped to make a pull request, but there are too many changes since RFCv2.
Any patches not referenced above did not have significant changes.

Comments are welcome.

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


[RFCv3 API PATCH 03/31] DocBook: improve STREAMON/OFF documentation.

2012-09-14 Thread Hans Verkuil
Specify that STREAMON/OFF should return 0 if the stream is already
started/stopped.

The spec never specified what the correct behavior is. This ambiguity
was resolved during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/DocBook/media/v4l/vidioc-streamon.xml |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-streamon.xml 
b/Documentation/DocBook/media/v4l/vidioc-streamon.xml
index 81cca45..716ea15 100644
--- a/Documentation/DocBook/media/v4l/vidioc-streamon.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-streamon.xml
@@ -74,7 +74,12 @@ not transmitted yet. I/O returns to the same state as after 
calling
 stream type. This is the same as v4l2-requestbuffers;
 structfieldtype/structfield./para
 
-paraNote applications can be preempted for unknown periods right
+paraIf constantVIDIOC_STREAMON/constant is called when streaming
+is already in progress, or if constantVIDIOC_STREAMOFF/constant is called
+when streaming is already stopped, then the ioctl does nothing and 0 is
+returned./para
+
+paraNote that applications can be preempted for unknown periods right
 before or after the constantVIDIOC_STREAMON/constant or
 constantVIDIOC_STREAMOFF/constant calls, there is no notion of
 starting or stopping now. Buffer timestamps can be used to
-- 
1.7.10.4

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


[RFCv3 API PATCH 07/31] v4l2-core: deprecate V4L2_BUF_TYPE_PRIVATE

2012-09-14 Thread Hans Verkuil
This buffer type isn't used at all, and since it is effectively undefined
what it should do it is deprecated. The define still exists, but any
internal support for such buffers is removed.

The decisions to deprecate this was taken during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c |8 
 drivers/media/v4l2-core/v4l2-dev.c|   12 
 drivers/media/v4l2-core/v4l2-ioctl.c  |   26 +
 include/linux/videodev2.h |1 +
 include/media/v4l2-ioctl.h|8 
 5 files changed, 6 insertions(+), 49 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 
b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index e843705..83ffb64 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -195,10 +195,6 @@ static int __get_v4l2_format32(struct v4l2_format *kp, 
struct v4l2_format32 __us
case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
return get_v4l2_sliced_vbi_format(kp-fmt.sliced, 
up-fmt.sliced);
-   case V4L2_BUF_TYPE_PRIVATE:
-   if (copy_from_user(kp, up, sizeof(kp-fmt.raw_data)))
-   return -EFAULT;
-   return 0;
default:
printk(KERN_INFO compat_ioctl32: unexpected VIDIOC_FMT type 
%d\n,
kp-type);
@@ -241,10 +237,6 @@ static int __put_v4l2_format32(struct v4l2_format *kp, 
struct v4l2_format32 __us
case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
return put_v4l2_sliced_vbi_format(kp-fmt.sliced, 
up-fmt.sliced);
-   case V4L2_BUF_TYPE_PRIVATE:
-   if (copy_to_user(up, kp, sizeof(up-fmt.raw_data)))
-   return -EFAULT;
-   return 0;
default:
printk(KERN_INFO compat_ioctl32: unexpected VIDIOC_FMT type 
%d\n,
kp-type);
diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index 71237f5..95f92ea 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -565,8 +565,7 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
ops-vidioc_enum_fmt_vid_out ||
ops-vidioc_enum_fmt_vid_cap_mplane ||
ops-vidioc_enum_fmt_vid_out_mplane ||
-   ops-vidioc_enum_fmt_vid_overlay ||
-   ops-vidioc_enum_fmt_type_private)
+   ops-vidioc_enum_fmt_vid_overlay)
set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
if (ops-vidioc_g_fmt_vid_cap ||
ops-vidioc_g_fmt_vid_out ||
@@ -577,8 +576,7 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
ops-vidioc_g_fmt_vid_out_overlay ||
ops-vidioc_g_fmt_vbi_out ||
ops-vidioc_g_fmt_sliced_vbi_cap ||
-   ops-vidioc_g_fmt_sliced_vbi_out ||
-   ops-vidioc_g_fmt_type_private)
+   ops-vidioc_g_fmt_sliced_vbi_out)
set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
if (ops-vidioc_s_fmt_vid_cap ||
ops-vidioc_s_fmt_vid_out ||
@@ -589,8 +587,7 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
ops-vidioc_s_fmt_vid_out_overlay ||
ops-vidioc_s_fmt_vbi_out ||
ops-vidioc_s_fmt_sliced_vbi_cap ||
-   ops-vidioc_s_fmt_sliced_vbi_out ||
-   ops-vidioc_s_fmt_type_private)
+   ops-vidioc_s_fmt_sliced_vbi_out)
set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
if (ops-vidioc_try_fmt_vid_cap ||
ops-vidioc_try_fmt_vid_out ||
@@ -601,8 +598,7 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
ops-vidioc_try_fmt_vid_out_overlay ||
ops-vidioc_try_fmt_vbi_out ||
ops-vidioc_try_fmt_sliced_vbi_cap ||
-   ops-vidioc_try_fmt_sliced_vbi_out ||
-   ops-vidioc_try_fmt_type_private)
+   ops-vidioc_try_fmt_sliced_vbi_out)
set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 932d9bf..449ca9c 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -316,9 +316,6 @@ static void v4l_print_format(const void *arg, bool 
write_only)
sliced-service_lines[0][i],
sliced-service_lines[1][i]);
break;
-   case V4L2_BUF_TYPE_PRIVATE:
-   pr_cont(\n);
-   break;
}
 }
 
@@ -927,10 +924,6 

[RFCv3 API PATCH 05/31] DocBook: bus_info can no longer be empty.

2012-09-14 Thread Hans Verkuil
During the 2012 Media Workshop it was decided that bus_info as returned
by VIDIOC_QUERYCAP can no longer be empty. It should be a unique identifier,
and empty strings are obviously not unique.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/DocBook/media/v4l/vidioc-querycap.xml |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-querycap.xml 
b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
index f33dd74..4c70215 100644
--- a/Documentation/DocBook/media/v4l/vidioc-querycap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
@@ -90,11 +90,13 @@ ambiguities./entry
entry__u8/entry
entrystructfieldbus_info/structfield[32]/entry
entryLocation of the device in the system, a
-NUL-terminated ASCII string. For example: PCI Slot 4. This
+NUL-terminated ASCII string. For example: PCI::05:06.0. This
 information is intended for users, to distinguish multiple
-identical devices. If no such information is available the field may
-simply count the devices controlled by the driver, or contain the
-empty string (structfieldbus_info/structfield[0] = 0).!-- XXX 
pci_dev-slot_name example --/entry
+identical devices. If no such information is available the field must
+simply count the devices controlled by the driver (platform:vivi-000).
+The bus_info must start with PCI: for PCI boards, PCIe: for PCI Express 
boards,
+usb- for USB devices, I2C: for i2c devices, ISA: for ISA devices,
+parport for parallel port devices and platform: for platform 
devices./entry
  /row
  row
entry__u32/entry
-- 
1.7.10.4

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


[RFCv3 API PATCH 04/31] DocBook: make the G/S/TRY_FMT specification more strict.

2012-09-14 Thread Hans Verkuil
- S/TRY_FMT should always succeed, unless an invalid type field is passed in.
- TRY_FMT should give the same result as S_FMT, all other things being equal.
- ENUMFMT may return different formats for different inputs or outputs.

This was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml |3 +++
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml|9 ++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml 
b/Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml
index 81ebe48..0bd3324 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml
@@ -58,6 +58,9 @@ structure. Drivers fill the rest of the structure or return an
 incrementing by one until errorcodeEINVAL/errorcode is
 returned./para
 
+paraNote that after switching input or output the list of enumerated 
image
+formats may be different./para
+
 table pgwide=1 frame=none id=v4l2-fmtdesc
   titlestruct structnamev4l2_fmtdesc/structname/title
   tgroup cols=3
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
index 52acff1..b4b0e0a 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
@@ -81,7 +81,7 @@ the application calls the constantVIDIOC_S_FMT/constant 
ioctl
 with a pointer to a structnamev4l2_format/structname structure
 the driver checks
 and adjusts the parameters against hardware abilities. Drivers
-should not return an error code unless the input is ambiguous, this is
+should not return an error code unless the structfieldtype/structfield 
field is invalid, this is
 a mechanism to fathom device capabilities and to approach parameters
 acceptable for both the application and driver. On success the driver
 may program the hardware, allocate resources and generally prepare for
@@ -107,6 +107,10 @@ disabling I/O or possibly time consuming hardware 
preparations.
 Although strongly recommended drivers are not required to implement
 this ioctl./para
 
+paraThe format as returned by constantVIDIOC_TRY_FMT/constant
+must be identical to what constantVIDIOC_S_FMT/constant returns for
+the same input or output./para
+
 table pgwide=1 frame=none id=v4l2-format
   titlestruct structnamev4l2_format/structname/title
   tgroup cols=4
@@ -187,8 +191,7 @@ capture and output devices./entry
termerrorcodeEINVAL/errorcode/term
listitem
  paraThe v4l2-format; structfieldtype/structfield
-field is invalid, the requested buffer type not supported, or the
-format is not supported with this buffer type./para
+field is invalid or the requested buffer type not supported./para
/listitem
   /varlistentry
 /variablelist
-- 
1.7.10.4

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


[RFCv3 API PATCH 01/31] v4l: Remove experimental tag from certain API elements

2012-09-14 Thread Hans Verkuil
From: Sakari Ailus sakari.ai...@iki.fi

Remove experimantal tag from the following API elements:

V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY buffer type.
V4L2_CAP_VIDEO_OUTPUT_OVERLAY capability flag.
VIDIOC_ENUM_FRAMESIZES IOCTL.
VIDIOC_ENUM_FRAMEINTERVALS IOCTL.
VIDIOC_G_ENC_INDEX IOCTL.
VIDIOC_ENCODER_CMD and VIDIOC_TRY_ENCODER_CMD IOCTLs.
VIDIOC_DECODER_CMD and VIDIOC_TRY_DECODER_CMD IOCTLs.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/compat.xml |   23 
 Documentation/DocBook/media/v4l/dev-osd.xml|7 --
 Documentation/DocBook/media/v4l/io.xml |3 +--
 .../DocBook/media/v4l/vidioc-decoder-cmd.xml   |7 --
 .../DocBook/media/v4l/vidioc-encoder-cmd.xml   |7 --
 .../DocBook/media/v4l/vidioc-enum-framesizes.xml   |7 --
 .../DocBook/media/v4l/vidioc-g-enc-index.xml   |7 --
 7 files changed, 1 insertion(+), 60 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index 98e8d08..578135e 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2555,29 +2555,6 @@ and may change in the future./para
  paraVideo Output Overlay (OSD) Interface, xref
linkend=osd /./para
 /listitem
-   listitem
- paraconstantV4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY/constant,
-   v4l2-buf-type;, xref linkend=v4l2-buf-type /./para
-/listitem
-listitem
- paraconstantV4L2_CAP_VIDEO_OUTPUT_OVERLAY/constant,
-VIDIOC-QUERYCAP; ioctl, xref linkend=device-capabilities /./para
-/listitem
-listitem
- paraVIDIOC-ENUM-FRAMESIZES; and
-VIDIOC-ENUM-FRAMEINTERVALS; ioctls./para
-/listitem
-listitem
- paraVIDIOC-G-ENC-INDEX; ioctl./para
-/listitem
-listitem
- paraVIDIOC-ENCODER-CMD; and VIDIOC-TRY-ENCODER-CMD;
-ioctls./para
-/listitem
-listitem
- paraVIDIOC-DECODER-CMD; and VIDIOC-TRY-DECODER-CMD;
-ioctls./para
-/listitem
 listitem
  paraVIDIOC-DBG-G-REGISTER; and VIDIOC-DBG-S-REGISTER;
 ioctls./para
diff --git a/Documentation/DocBook/media/v4l/dev-osd.xml 
b/Documentation/DocBook/media/v4l/dev-osd.xml
index 479d943..dd91d61 100644
--- a/Documentation/DocBook/media/v4l/dev-osd.xml
+++ b/Documentation/DocBook/media/v4l/dev-osd.xml
@@ -1,13 +1,6 @@
   titleVideo Output Overlay Interface/title
   subtitleAlso known as On-Screen Display (OSD)/subtitle
 
-  note
-titleExperimental/title
-
-paraThis is an link linkend=experimentalexperimental/link
-interface and may change in the future./para
-  /note
-
   paraSome video output devices can overlay a framebuffer image onto
 the outgoing video signal. Applications can set up such an overlay
 using this interface, which borrows structures and ioctls of the link
diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 1885cc0..2512649 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -827,8 +827,7 @@ should set this to 0./entry

entryconstantV4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY/constant/entry
entry8/entry
entryBuffer for video output overlay (OSD), see xref
-   linkend=osd /. Status: link
-linkend=experimentalExperimental/link./entry
+   linkend=osd /./entry
  /row
  row
entryconstantV4L2_BUF_TYPE_PRIVATE/constant/entry
diff --git a/Documentation/DocBook/media/v4l/vidioc-decoder-cmd.xml 
b/Documentation/DocBook/media/v4l/vidioc-decoder-cmd.xml
index 74b87f6..9215627 100644
--- a/Documentation/DocBook/media/v4l/vidioc-decoder-cmd.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-decoder-cmd.xml
@@ -49,13 +49,6 @@
   refsect1
 titleDescription/title
 
-note
-  titleExperimental/title
-
-  paraThis is an link linkend=experimentalexperimental/link
-interface and may change in the future./para
-/note
-
 paraThese ioctls control an audio/video (usually MPEG-) decoder.
 constantVIDIOC_DECODER_CMD/constant sends a command to the
 decoder, constantVIDIOC_TRY_DECODER_CMD/constant can be used to
diff --git a/Documentation/DocBook/media/v4l/vidioc-encoder-cmd.xml 
b/Documentation/DocBook/media/v4l/vidioc-encoder-cmd.xml
index f431b3b..0619ca5 100644
--- a/Documentation/DocBook/media/v4l/vidioc-encoder-cmd.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-encoder-cmd.xml
@@ -49,13 +49,6 @@
   refsect1
 titleDescription/title
 
-note
-  titleExperimental/title
-
-  paraThis is an link linkend=experimentalexperimental/link
-interface and may change in the future./para
-/note
-
 paraThese ioctls control an audio/video (usually MPEG-) encoder.
 constantVIDIOC_ENCODER_CMD/constant sends a command to the
 encoder, 

[RFCv3 API PATCH 10/31] DocBook: document when to return ENODATA.

2012-09-14 Thread Hans Verkuil
ENODATA should be returned if the API used for getting, changing, querying
or enumerating the current video timings is not supported by the current input
or output.

This was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 .../DocBook/media/v4l/vidioc-enum-dv-presets.xml  |6 ++
 .../DocBook/media/v4l/vidioc-enum-dv-timings.xml  |6 ++
 Documentation/DocBook/media/v4l/vidioc-enumstd.xml|6 ++
 Documentation/DocBook/media/v4l/vidioc-g-dv-preset.xml|9 ++---
 Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml   |   13 +
 Documentation/DocBook/media/v4l/vidioc-g-std.xml  |   10 +-
 .../DocBook/media/v4l/vidioc-query-dv-preset.xml  |9 +
 .../DocBook/media/v4l/vidioc-query-dv-timings.xml |6 ++
 Documentation/DocBook/media/v4l/vidioc-querystd.xml   |8 
 9 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-dv-presets.xml 
b/Documentation/DocBook/media/v4l/vidioc-enum-dv-presets.xml
index 509f001..fced5fb 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enum-dv-presets.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enum-dv-presets.xml
@@ -229,6 +229,12 @@ intended for the user./entry
 is out of bounds./para
/listitem
   /varlistentry
+  varlistentry
+   termerrorcodeENODATA/errorcode/term
+   listitem
+ paraDigital video presets are not supported for this input or 
output./para
+   /listitem
+  /varlistentry
 /variablelist
   /refsect1
 /refentry
diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml 
b/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml
index 24c3bf4..b3e17c1 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml
@@ -106,6 +106,12 @@ application./entry
 is out of bounds./para
/listitem
   /varlistentry
+  varlistentry
+   termerrorcodeENODATA/errorcode/term
+   listitem
+ paraDigital video presets are not supported for this input or 
output./para
+   /listitem
+  /varlistentry
 /variablelist
   /refsect1
 /refentry
diff --git a/Documentation/DocBook/media/v4l/vidioc-enumstd.xml 
b/Documentation/DocBook/media/v4l/vidioc-enumstd.xml
index 3a5fc54..8065099 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enumstd.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enumstd.xml
@@ -378,6 +378,12 @@ system)/para/footnote/para/entry
 is out of bounds./para
/listitem
   /varlistentry
+  varlistentry
+   termerrorcodeENODATA/errorcode/term
+   listitem
+ paraStandard video timings are not supported for this input or 
output./para
+   /listitem
+  /varlistentry
 /variablelist
   /refsect1
 /refentry
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-dv-preset.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-dv-preset.xml
index 61be9fa..b9ea376 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-dv-preset.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-dv-preset.xml
@@ -78,6 +78,12 @@ If the preset is not supported, it returns an EINVAL; 
/para
/listitem
   /varlistentry
   varlistentry
+   termerrorcodeENODATA/errorcode/term
+   listitem
+ paraDigital video presets are not supported for this input or 
output./para
+   /listitem
+  /varlistentry
+  varlistentry
termerrorcodeEBUSY/errorcode/term
listitem
  paraThe device is busy and therefore can not change the 
preset./para
@@ -104,7 +110,4 @@ If the preset is not supported, it returns an EINVAL; 
/para
   /tgroup
 /table
   /refsect1
-  refsect1
-return-value;
-  /refsect1
 /refentry
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml
index eda1a29..feaa180 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml
@@ -56,7 +56,9 @@ a pointer to the v4l2-dv-timings; structure as argument. If 
the ioctl is not su
 or the timing values are not correct, the driver returns EINVAL;./para
 paraThe filenamelinux/v4l2-dv-timings.h/filename header can be used to 
get the
 timings of the formats in the xref linkend=cea861 / and xref 
linkend=vesadmt /
-standards./para
+standards. If the current input or output does not support DV timings (e.g. if
+VIDIOC-ENUMINPUT; does not set the 
constantV4L2_IN_CAP_CUSTOM_TIMINGS/constant flag), then
+ENODATA; is returned./para
   /refsect1
 
   refsect1
@@ -71,6 +73,12 @@ standards./para
/listitem
   /varlistentry
   varlistentry
+   termerrorcodeENODATA/errorcode/term
+   listitem
+ paraDigital video timings are not supported for this input or 
output./para
+   /listitem
+  

[RFCv3 API PATCH 13/31] Feature removal: Remove CUSTOM_TIMINGS defines in 3.9.

2012-09-14 Thread Hans Verkuil
These have been replaced by new defines without the CUSTOM_ part.
Get rid of the old ones.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/feature-removal-schedule.txt |9 +
 1 file changed, 9 insertions(+)

diff --git a/Documentation/feature-removal-schedule.txt 
b/Documentation/feature-removal-schedule.txt
index a52924e..4f7e6ad 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -646,3 +646,12 @@ Who:   Russell King li...@arm.linux.org.uk,
Santosh Shilimkar santosh.shilim...@ti.com
 
 
+
+What:  Remove deprecated DV timings capability defines 
V4L2_IN_CAP_CUSTOM_TIMINGS
+   and V4L2_OUT_CAP_CUSTOM_TIMINGS.
+When:  3.9
+Why:   These defines have been replaced by V4L2_IN_CAP_TIMINGS and
+   V4L2_OUT_CAP_TIMINGS respectively.
+Who:   Hans Verkuil hans.verk...@cisco.com
+
+
-- 
1.7.10.4

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


[RFCv3 API PATCH 09/31] v4l2: remove experimental tag from a number of old drivers.

2012-09-14 Thread Hans Verkuil
A number of old drivers still had the experimental tag. Time to remove it.

It concerns the following drivers:

VIDEO_TLV320AIC23B
USB_STKWEBCAM
VIDEO_CX18
VIDEO_CX18_ALSA
VIDEO_ZORAN_AVS6EYES
DVB_USB_AF9005
MEDIA_TUNER_TEA5761
VIDEO_NOON010PC30

This decision was taken during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/media/i2c/Kconfig   |4 ++--
 drivers/media/pci/cx18/Kconfig  |4 ++--
 drivers/media/pci/zoran/Kconfig |4 ++--
 drivers/media/tuners/Kconfig|5 ++---
 drivers/media/usb/dvb-usb/Kconfig   |2 +-
 drivers/media/usb/stkwebcam/Kconfig |2 +-
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 0e0793a..d3be0ca 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -117,7 +117,7 @@ config VIDEO_CS53L32A
 
 config VIDEO_TLV320AIC23B
tristate Texas Instruments TLV320AIC23B audio codec
-   depends on VIDEO_V4L2  I2C  EXPERIMENTAL
+   depends on VIDEO_V4L2  I2C
---help---
  Support for the Texas Instruments TLV320AIC23B audio codec.
 
@@ -492,7 +492,7 @@ config VIDEO_SR030PC30
 
 config VIDEO_NOON010PC30
tristate Siliconfile NOON010PC30 sensor support
-   depends on I2C  VIDEO_V4L2  EXPERIMENTAL  VIDEO_V4L2_SUBDEV_API
+   depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API
depends on MEDIA_CAMERA_SUPPORT
---help---
  This driver supports NOON010PC30 CIF camera from Siliconfile
diff --git a/drivers/media/pci/cx18/Kconfig b/drivers/media/pci/cx18/Kconfig
index 9a9f765..c675b83 100644
--- a/drivers/media/pci/cx18/Kconfig
+++ b/drivers/media/pci/cx18/Kconfig
@@ -1,6 +1,6 @@
 config VIDEO_CX18
tristate Conexant cx23418 MPEG encoder support
-   depends on VIDEO_V4L2  DVB_CORE  PCI  I2C  EXPERIMENTAL
+   depends on VIDEO_V4L2  DVB_CORE  PCI  I2C
select I2C_ALGOBIT
select VIDEOBUF_VMALLOC
depends on RC_CORE
@@ -25,7 +25,7 @@ config VIDEO_CX18
 
 config VIDEO_CX18_ALSA
tristate Conexant 23418 DMA audio support
-   depends on VIDEO_CX18  SND  EXPERIMENTAL
+   depends on VIDEO_CX18  SND
select SND_PCM
---help---
  This is a video4linux driver for direct (DMA) audio on
diff --git a/drivers/media/pci/zoran/Kconfig b/drivers/media/pci/zoran/Kconfig
index a9b2318..26ca870 100644
--- a/drivers/media/pci/zoran/Kconfig
+++ b/drivers/media/pci/zoran/Kconfig
@@ -65,8 +65,8 @@ config VIDEO_ZORAN_LML33R10
  card.
 
 config VIDEO_ZORAN_AVS6EYES
-   tristate AverMedia 6 Eyes support (EXPERIMENTAL)
-   depends on VIDEO_ZORAN_ZR36060  EXPERIMENTAL
+   tristate AverMedia 6 Eyes support
+   depends on VIDEO_ZORAN_ZR36060
select VIDEO_BT856 if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_BT866 if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_KS0127 if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig
index 80238b9..901d886 100644
--- a/drivers/media/tuners/Kconfig
+++ b/drivers/media/tuners/Kconfig
@@ -28,7 +28,7 @@ config MEDIA_TUNER
select MEDIA_TUNER_XC4000 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_MT20XX if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_TDA8290 if MEDIA_SUBDRV_AUTOSELECT
-   select MEDIA_TUNER_TEA5761 if MEDIA_SUBDRV_AUTOSELECT  
MEDIA_RADIO_SUPPORT  EXPERIMENTAL
+   select MEDIA_TUNER_TEA5761 if MEDIA_SUBDRV_AUTOSELECT  
MEDIA_RADIO_SUPPORT
select MEDIA_TUNER_TEA5767 if MEDIA_SUBDRV_AUTOSELECT  
MEDIA_RADIO_SUPPORT
select MEDIA_TUNER_SIMPLE if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_TDA9887 if MEDIA_SUBDRV_AUTOSELECT
@@ -78,9 +78,8 @@ config MEDIA_TUNER_TDA9887
  analog IF demodulator.
 
 config MEDIA_TUNER_TEA5761
-   tristate TEA 5761 radio tuner (EXPERIMENTAL)
+   tristate TEA 5761 radio tuner
depends on MEDIA_SUPPORT  I2C
-   depends on EXPERIMENTAL
default m if !MEDIA_SUBDRV_AUTOSELECT
help
  Say Y here to include support for the Philips TEA5761 radio tuner.
diff --git a/drivers/media/usb/dvb-usb/Kconfig 
b/drivers/media/usb/dvb-usb/Kconfig
index 3c5fff8..fa0b293 100644
--- a/drivers/media/usb/dvb-usb/Kconfig
+++ b/drivers/media/usb/dvb-usb/Kconfig
@@ -227,7 +227,7 @@ config DVB_USB_OPERA1
 
 config DVB_USB_AF9005
tristate Afatech AF9005 DVB-T USB1.1 support
-   depends on DVB_USB  EXPERIMENTAL
+   depends on DVB_USB
select MEDIA_TUNER_MT2060 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT
help
diff --git a/drivers/media/usb/stkwebcam/Kconfig 
b/drivers/media/usb/stkwebcam/Kconfig
index 2fb0c2b..a6a00aa 100644
--- a/drivers/media/usb/stkwebcam/Kconfig
+++ b/drivers/media/usb/stkwebcam/Kconfig
@@ -1,6 +1,6 @@
 config USB_STKWEBCAM
tristate USB Syntek DC1125 

[RFCv3 API PATCH 19/31] v4l2: make vidioc_s_fbuf const.

2012-09-14 Thread Hans Verkuil
Write-only ioctls should have a const argument in the ioctl op.

Do this conversion for vidioc_s_fbuf.

Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/common/saa7146/saa7146_video.c |2 +-
 drivers/media/pci/bt8xx/bttv-driver.c|2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c  |4 ++--
 drivers/media/pci/saa7134/saa7134-video.c|2 +-
 drivers/media/pci/zoran/zoran_driver.c   |2 +-
 drivers/media/platform/fsl-viu.c |2 +-
 drivers/media/platform/omap/omap_vout.c  |2 +-
 include/media/v4l2-ioctl.h   |2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_video.c 
b/drivers/media/common/saa7146/saa7146_video.c
index 6d14785..4143d61 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -479,7 +479,7 @@ static int vidioc_g_fbuf(struct file *file, void *fh, 
struct v4l2_framebuffer *f
return 0;
 }
 
-static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer 
*fb)
+static int vidioc_s_fbuf(struct file *file, void *fh, const struct 
v4l2_framebuffer *fb)
 {
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)-dev;
struct saa7146_vv *vv = dev-vv_data;
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index b58ff87..26bf309 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -2740,7 +2740,7 @@ static int bttv_overlay(struct file *file, void *f, 
unsigned int on)
 }
 
 static int bttv_s_fbuf(struct file *file, void *f,
-   struct v4l2_framebuffer *fb)
+   const struct v4l2_framebuffer *fb)
 {
struct bttv_fh *fh = f;
struct bttv *btv = fh-btv;
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 32a5910..d3b32c2 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -1427,7 +1427,7 @@ static int ivtv_g_fbuf(struct file *file, void *fh, 
struct v4l2_framebuffer *fb)
return 0;
 }
 
-static int ivtv_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer 
*fb)
+static int ivtv_s_fbuf(struct file *file, void *fh, const struct 
v4l2_framebuffer *fb)
 {
struct ivtv_open_id *id = fh2id(fh);
struct ivtv *itv = id-itv;
@@ -1444,7 +1444,7 @@ static int ivtv_s_fbuf(struct file *file, void *fh, 
struct v4l2_framebuffer *fb)
itv-osd_chroma_key_state = (fb-flags  V4L2_FBUF_FLAG_CHROMAKEY) != 0;
ivtv_set_osd_alpha(itv);
yi-track_osd = (fb-flags  V4L2_FBUF_FLAG_OVERLAY) != 0;
-   return ivtv_g_fbuf(file, fh, fb);
+   return 0;
 }
 
 static int ivtv_overlay(struct file *file, void *fh, unsigned int on)
diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index 6de10b1..bac4386 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2158,7 +2158,7 @@ static int saa7134_g_fbuf(struct file *file, void *f,
 }
 
 static int saa7134_s_fbuf(struct file *file, void *f,
-   struct v4l2_framebuffer *fb)
+   const struct v4l2_framebuffer *fb)
 {
struct saa7134_fh *fh = f;
struct saa7134_dev *dev = fh-dev;
diff --git a/drivers/media/pci/zoran/zoran_driver.c 
b/drivers/media/pci/zoran/zoran_driver.c
index c6ccdeb..f91b551 100644
--- a/drivers/media/pci/zoran/zoran_driver.c
+++ b/drivers/media/pci/zoran/zoran_driver.c
@@ -1978,7 +1978,7 @@ static int zoran_g_fbuf(struct file *file, void *__fh,
 }
 
 static int zoran_s_fbuf(struct file *file, void *__fh,
-   struct v4l2_framebuffer *fb)
+   const struct v4l2_framebuffer *fb)
 {
struct zoran_fh *fh = __fh;
struct zoran *zr = fh-zr;
diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index 20f9810..897250b 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -860,7 +860,7 @@ int vidioc_g_fbuf(struct file *file, void *priv, struct 
v4l2_framebuffer *arg)
return 0;
 }
 
-int vidioc_s_fbuf(struct file *file, void *priv, struct v4l2_framebuffer *arg)
+int vidioc_s_fbuf(struct file *file, void *priv, const struct v4l2_framebuffer 
*arg)
 {
struct viu_fh  *fh = priv;
struct viu_dev *dev = fh-dev;
diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index 88cf9d9..92845f8 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -1744,7 +1744,7 @@ static int vidioc_streamoff(struct file *file, void *fh, 
enum v4l2_buf_type i)
 }
 
 static int vidioc_s_fbuf(struct file *file, void *fh,
-

[RFCv3 API PATCH 11/31] v4l2-core: tvnorms may be 0 for a given input, handle that case.

2012-09-14 Thread Hans Verkuil
Currently the core code looks at tvnorms to see whether ENUMSTD
or G_PARM should be enabled. This is not a good check for drivers
that support the STD API on one input and the DV Timings API on another.

In that case tvnorms may be 0.

Instead check whether s_std is present (for ENUMSTD) or whether g_std or
current_norm is present for g_parm.

Also, in the enumstd core function return ENODATA if tvnorms is 0,
because in that case the current input does not support the STD API
and ENUMSTD should return ENODATA for that.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-dev.c   |4 ++--
 drivers/media/v4l2-core/v4l2-ioctl.c |5 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index 95f92ea..498049f 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -609,7 +609,7 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
SET_VALID_IOCTL(ops, VIDIOC_S_FBUF, vidioc_s_fbuf);
SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon);
SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff);
-   if (vdev-tvnorms)
+   if (ops-vidioc_s_std)
set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls);
if (ops-vidioc_g_std || vdev-current_norm)
set_bit(_IOC_NR(VIDIOC_G_STD), valid_ioctls);
@@ -663,7 +663,7 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
SET_VALID_IOCTL(ops, VIDIOC_DECODER_CMD, vidioc_decoder_cmd);
SET_VALID_IOCTL(ops, VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd);
if (ops-vidioc_g_parm || (vdev-vfl_type == VFL_TYPE_GRABBER 
-   (ops-vidioc_g_std || vdev-tvnorms)))
+   (ops-vidioc_g_std || 
vdev-current_norm)))
set_bit(_IOC_NR(VIDIOC_G_PARM), valid_ioctls);
SET_VALID_IOCTL(ops, VIDIOC_S_PARM, vidioc_s_parm);
SET_VALID_IOCTL(ops, VIDIOC_G_TUNER, vidioc_g_tuner);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 449ca9c..4ee9158 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1302,6 +1302,11 @@ static int v4l_enumstd(const struct v4l2_ioctl_ops *ops,
unsigned int index = p-index, i, j = 0;
const char *descr = ;
 
+   /* Return -ENODATA if the tvnorms for the current input
+  or output is 0, meaning that it doesn't support this API. */
+   if (id == 0)
+   return -ENODATA;
+
/* Return norm array in a canonical way */
for (i = 0; i = index  id; i++) {
/* last std value in the standards array is 0, so this
-- 
1.7.10.4

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


[RFCv3 API PATCH 08/31] DocBook: deprecate V4L2_BUF_TYPE_PRIVATE.

2012-09-14 Thread Hans Verkuil
As per decision taken during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/compat.xml  |2 +-
 Documentation/DocBook/media/v4l/io.xml  |   14 ++
 Documentation/DocBook/media/v4l/vidioc-cropcap.xml  |6 ++
 Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml |6 ++
 Documentation/DocBook/media/v4l/vidioc-g-crop.xml   |6 ++
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml|4 +---
 Documentation/DocBook/media/v4l/vidioc-g-parm.xml   |4 +---
 Documentation/DocBook/media/v4l/vidioc-reqbufs.xml  |5 ++---
 8 files changed, 13 insertions(+), 34 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index 578135e..c6ae4c9 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -1476,7 +1476,7 @@ follows.informaltable
  /row
  row

entryconstantV4L2_BUF_TYPE_PRIVATE_BASE/constant/entry
-   entryconstantV4L2_BUF_TYPE_PRIVATE/constant/entry
+   entryconstantV4L2_BUF_TYPE_PRIVATE/constant (but this 
is deprecated)/entry
  /row
/tbody
  /tgroup
diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 2512649..2dc39d8 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -685,18 +685,14 @@ memory, set by the application. See xref linkend=userp 
/ for details.
entry__u32/entry
entrystructfieldreserved2/structfield/entry
entry/entry
-   entryA place holder for future extensions and custom
-(driver defined) buffer types
-constantV4L2_BUF_TYPE_PRIVATE/constant and higher. Applications
+   entryA place holder for future extensions. Applications
 should set this to 0./entry
  /row
  row
entry__u32/entry
entrystructfieldreserved/structfield/entry
entry/entry
-   entryA place holder for future extensions and custom
-(driver defined) buffer types
-constantV4L2_BUF_TYPE_PRIVATE/constant and higher. Applications
+   entryA place holder for future extensions. Applications
 should set this to 0./entry
  /row
/tbody
@@ -829,12 +825,6 @@ should set this to 0./entry
entryBuffer for video output overlay (OSD), see xref
linkend=osd /./entry
  /row
- row
-   entryconstantV4L2_BUF_TYPE_PRIVATE/constant/entry
-   entry0x80/entry
- entryThis and higher values are reserved for custom
-(driver defined) buffer types./entry
- /row
/tbody
   /tgroup
 /table
diff --git a/Documentation/DocBook/media/v4l/vidioc-cropcap.xml 
b/Documentation/DocBook/media/v4l/vidioc-cropcap.xml
index f1bac2c..4559c45 100644
--- a/Documentation/DocBook/media/v4l/vidioc-cropcap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-cropcap.xml
@@ -70,10 +70,8 @@ output./para
entryType of the data stream, set by the application.
 Only these types are valid here:
 constantV4L2_BUF_TYPE_VIDEO_CAPTURE/constant,
-constantV4L2_BUF_TYPE_VIDEO_OUTPUT/constant,
-constantV4L2_BUF_TYPE_VIDEO_OVERLAY/constant, and custom (driver
-defined) types with code constantV4L2_BUF_TYPE_PRIVATE/constant
-and higher. See xref linkend=v4l2-buf-type /./entry
+constantV4L2_BUF_TYPE_VIDEO_OUTPUT/constant and
+constantV4L2_BUF_TYPE_VIDEO_OVERLAY/constant. See xref 
linkend=v4l2-buf-type /./entry
  /row
  row
entrystruct link 
linkend=v4l2-rect-cropv4l2_rect/link/entry
diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml 
b/Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml
index 0bd3324..f8dfeed 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enum-fmt.xml
@@ -81,10 +81,8 @@ Only these types are valid here:
 constantV4L2_BUF_TYPE_VIDEO_CAPTURE/constant,
 constantV4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE/constant,
 constantV4L2_BUF_TYPE_VIDEO_OUTPUT/constant,
-constantV4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE/constant,
-constantV4L2_BUF_TYPE_VIDEO_OVERLAY/constant, and custom (driver
-defined) types with code constantV4L2_BUF_TYPE_PRIVATE/constant
-and higher. See xref linkend=v4l2-buf-type /./entry
+constantV4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE/constant and
+constantV4L2_BUF_TYPE_VIDEO_OVERLAY/constant. See xref 
linkend=v4l2-buf-type /./entry
  /row
  row
entry__u32/entry
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-crop.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-crop.xml
index c4ff3b1..75c6a93 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-crop.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-crop.xml
@@ -104,10 +104,8 @@ changed and constantVIDIOC_S_CROP/constant returns 

[RFCv3 API PATCH 28/31] Set vfl_dir for all display or m2m drivers.

2012-09-14 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/pci/ivtv/ivtv-streams.c |3 +++
 drivers/media/pci/zoran/zoran_card.c  |4 
 drivers/media/platform/coda.c |1 +
 drivers/media/platform/davinci/vpbe_display.c |1 +
 drivers/media/platform/davinci/vpif_display.c |1 +
 drivers/media/platform/m2m-deinterlace.c  |1 +
 drivers/media/platform/mem2mem_testdev.c  |1 +
 drivers/media/platform/mx2_emmaprp.c  |1 +
 drivers/media/platform/omap/omap_vout.c   |1 +
 drivers/media/platform/omap3isp/ispvideo.c|1 +
 drivers/media/platform/s5p-fimc/fimc-m2m.c|1 +
 drivers/media/platform/s5p-g2d/g2d.c  |1 +
 drivers/media/platform/s5p-jpeg/jpeg-core.c   |1 +
 drivers/media/platform/s5p-mfc/s5p_mfc.c  |1 +
 drivers/media/platform/s5p-tv/mixer_video.c   |1 +
 drivers/media/platform/sh_vou.c   |1 +
 drivers/media/usb/uvc/uvc_driver.c|2 ++
 17 files changed, 23 insertions(+)

diff --git a/drivers/media/pci/ivtv/ivtv-streams.c 
b/drivers/media/pci/ivtv/ivtv-streams.c
index f08ec17..1d0e04a 100644
--- a/drivers/media/pci/ivtv/ivtv-streams.c
+++ b/drivers/media/pci/ivtv/ivtv-streams.c
@@ -223,6 +223,9 @@ static int ivtv_prep_dev(struct ivtv *itv, int type)
 
s-vdev-num = num;
s-vdev-v4l2_dev = itv-v4l2_dev;
+   if (ivtv_stream_info[type].buf_type == V4L2_BUF_TYPE_VIDEO_OUTPUT ||
+   ivtv_stream_info[type].buf_type == V4L2_BUF_TYPE_VBI_OUTPUT)
+   s-vdev-vfl_dir = VFL_DIR_TX;
s-vdev-fops = ivtv_stream_info[type].fops;
s-vdev-ctrl_handler = itv-v4l2_dev.ctrl_handler;
s-vdev-release = video_device_release;
diff --git a/drivers/media/pci/zoran/zoran_card.c 
b/drivers/media/pci/zoran/zoran_card.c
index c3602d6..fffc54b 100644
--- a/drivers/media/pci/zoran/zoran_card.c
+++ b/drivers/media/pci/zoran/zoran_card.c
@@ -1055,6 +1055,10 @@ zr36057_init (struct zoran *zr)
memcpy(zr-video_dev, zoran_template, sizeof(zoran_template));
zr-video_dev-parent = zr-pci_dev-dev;
strcpy(zr-video_dev-name, ZR_DEVNAME(zr));
+   /* It's not a mem2mem device, but you can both capture and output from
+  one and the same device. This should really be split up into two
+  device nodes, but that's a job for another day. */
+   zr-video_dev-vfl_dir = VFL_DIR_M2M;
err = video_register_device(zr-video_dev, VFL_TYPE_GRABBER, 
video_nr[zr-id]);
if (err  0)
goto exit_free;
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 6908514..c483a6c 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -1641,6 +1641,7 @@ static void coda_fw_callback(const struct firmware *fw, 
void *context)
dev-vfd.release= video_device_release_empty,
dev-vfd.lock   = dev-dev_mutex;
dev-vfd.v4l2_dev   = dev-v4l2_dev;
+   dev-vfd.vfl_dir= VFL_DIR_M2M;
snprintf(dev-vfd.name, sizeof(dev-vfd.name), %s, CODA_NAME);
video_set_drvdata(dev-vfd, dev);
 
diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index f13713a..33a49b8 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1634,6 +1634,7 @@ static __devinit int init_vpbe_layer(int i, struct 
vpbe_display *disp_dev,
vbd-minor  = -1;
vbd-v4l2_dev   = disp_dev-vpbe_dev-v4l2_dev;
vbd-lock   = vpbe_display_layer-opslock;
+   vbd-vfl_dir= VFL_DIR_TX;
 
if (disp_dev-vpbe_dev-current_timings.timings_type 
VPBE_ENC_STD) {
diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index 4a24848..ff6e432 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1745,6 +1745,7 @@ static __init int vpif_probe(struct platform_device *pdev)
*vfd = vpif_video_template;
vfd-v4l2_dev = vpif_obj.v4l2_dev;
vfd-release = video_device_release;
+   vfd-vfl_dir = VFL_DIR_TX;
snprintf(vfd-name, sizeof(vfd-name),
 VPIF_Display_DRIVER_V%s,
 VPIF_DISPLAY_VERSION);
diff --git a/drivers/media/platform/m2m-deinterlace.c 
b/drivers/media/platform/m2m-deinterlace.c
index a38c152..a534a9c 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -982,6 +982,7 @@ static struct video_device deinterlace_videodev = {
.ioctl_ops  = deinterlace_ioctl_ops,
.minor  = -1,
.release= video_device_release,
+   .vfl_dir= VFL_DIR_M2M,
 };
 
 static struct v4l2_m2m_ops m2m_ops = {
diff --git a/drivers/media/platform/mem2mem_testdev.c 

[RFCv3 API PATCH 23/31] v4l2: make vidioc_s_audio const.

2012-09-14 Thread Hans Verkuil
Write-only ioctls should have a const argument in the ioctl op.

Do this conversion for vidioc_s_audio.

Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/pci/bt8xx/bttv-driver.c |4 ++--
 drivers/media/pci/cx18/cx18-ioctl.c   |2 +-
 drivers/media/pci/cx23885/cx23885-video.c |2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c   |2 +-
 drivers/media/pci/saa7134/saa7134-video.c |4 ++--
 drivers/media/pci/saa7146/mxb.c   |2 +-
 drivers/media/pci/ttpci/av7110_v4l.c  |2 +-
 drivers/media/radio/radio-miropcm20.c |2 +-
 drivers/media/radio/radio-sf16fmi.c   |2 +-
 drivers/media/radio/radio-tea5764.c   |2 +-
 drivers/media/radio/radio-timb.c  |2 +-
 drivers/media/radio/radio-wl1273.c|2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |2 +-
 drivers/media/usb/au0828/au0828-video.c   |2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c |4 ++--
 drivers/media/usb/em28xx/em28xx-video.c   |4 ++--
 drivers/media/usb/hdpvr/hdpvr-video.c |2 +-
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c  |2 +-
 drivers/media/usb/tlg2300/pd-radio.c  |2 +-
 drivers/media/usb/tlg2300/pd-video.c  |2 +-
 drivers/media/usb/tm6000/tm6000-video.c   |2 +-
 drivers/media/usb/usbvision/usbvision-video.c |2 +-
 include/media/v4l2-ioctl.h|2 +-
 23 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index 26bf309..31b2826 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3076,7 +3076,7 @@ static int bttv_g_audio(struct file *file, void *priv, 
struct v4l2_audio *a)
return 0;
 }
 
-static int bttv_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
+static int bttv_s_audio(struct file *file, void *priv, const struct v4l2_audio 
*a)
 {
if (unlikely(a-index))
return -EINVAL;
@@ -3480,7 +3480,7 @@ static int radio_s_tuner(struct file *file, void *priv,
 }
 
 static int radio_s_audio(struct file *file, void *priv,
-   struct v4l2_audio *a)
+   const struct v4l2_audio *a)
 {
if (unlikely(a-index))
return -EINVAL;
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c 
b/drivers/media/pci/cx18/cx18-ioctl.c
index 51675bc..ffc00ef 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -492,7 +492,7 @@ static int cx18_g_audio(struct file *file, void *fh, struct 
v4l2_audio *vin)
return cx18_get_audio_input(cx, vin-index, vin);
 }
 
-static int cx18_s_audio(struct file *file, void *fh, struct v4l2_audio *vout)
+static int cx18_s_audio(struct file *file, void *fh, const struct v4l2_audio 
*vout)
 {
struct cx18 *cx = fh2id(fh)-cx;
 
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index 22f8e7f..8c4a9a5 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -1426,7 +1426,7 @@ static int vidioc_g_audinput(struct file *file, void 
*priv,
 }
 
 static int vidioc_s_audinput(struct file *file, void *priv,
-   struct v4l2_audio *i)
+   const struct v4l2_audio *i)
 {
struct cx23885_dev *dev = ((struct cx23885_fh *)priv)-dev;
if (i-index = 2)
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 966abb4..99e35dd 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -784,7 +784,7 @@ static int ivtv_g_audio(struct file *file, void *fh, struct 
v4l2_audio *vin)
return ivtv_get_audio_input(itv, vin-index, vin);
 }
 
-static int ivtv_s_audio(struct file *file, void *fh, struct v4l2_audio *vout)
+static int ivtv_s_audio(struct file *file, void *fh, const struct v4l2_audio 
*vout)
 {
struct ivtv *itv = fh2id(fh)-itv;
 
diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index bac4386..135bfd8 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2089,7 +2089,7 @@ static int saa7134_g_audio(struct file *file, void *priv, 
struct v4l2_audio *a)
return 0;
 }
 
-static int saa7134_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
+static int saa7134_s_audio(struct file *file, void *priv, const struct 
v4l2_audio *a)
 {
return 0;
 }
@@ -2373,7 +2373,7 @@ static int radio_g_audio(struct file *file, void *priv,
 }
 
 static int radio_s_audio(struct file *file, void *priv,
-   struct v4l2_audio *a)
+   const struct 

[RFCv3 API PATCH 21/31] v4l2: make vidioc_s_freq_hw_seek const.

2012-09-14 Thread Hans Verkuil
Write-only ioctls should have a const argument in the ioctl op.

Do this conversion for vidioc_s_freq_hw_seek.

Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/radio/radio-mr800.c|2 +-
 drivers/media/radio/radio-tea5777.c  |   32 --
 drivers/media/radio/radio-wl1273.c   |2 +-
 drivers/media/radio/si470x/radio-si470x-common.c |4 +--
 drivers/media/radio/wl128x/fmdrv_v4l2.c  |2 +-
 include/media/v4l2-ioctl.h   |2 +-
 sound/i2c/other/tea575x-tuner.c  |2 +-
 7 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/drivers/media/radio/radio-mr800.c 
b/drivers/media/radio/radio-mr800.c
index 3182b26..720bf0d 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -348,7 +348,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 }
 
 static int vidioc_s_hw_freq_seek(struct file *file, void *priv,
-   struct v4l2_hw_freq_seek *seek)
+   const struct v4l2_hw_freq_seek *seek)
 {
static u8 buf[8] = {
0x3d, 0x32, 0x0f, 0x08, 0x3d, 0x32, 0x0f, 0x08
diff --git a/drivers/media/radio/radio-tea5777.c 
b/drivers/media/radio/radio-tea5777.c
index ef82898..c1a2ea6 100644
--- a/drivers/media/radio/radio-tea5777.c
+++ b/drivers/media/radio/radio-tea5777.c
@@ -385,59 +385,61 @@ static int vidioc_s_frequency(struct file *file, void 
*priv,
 }
 
 static int vidioc_s_hw_freq_seek(struct file *file, void *fh,
-   struct v4l2_hw_freq_seek *a)
+   const struct v4l2_hw_freq_seek *a)
 {
struct radio_tea5777 *tea = video_drvdata(file);
unsigned long timeout;
+   u32 rangelow = a-rangelow;
+   u32 rangehigh = a-rangehigh;
int i, res, spacing;
u32 orig_freq;
 
if (a-tuner || a-wrap_around)
return -EINVAL;
 
-   if (a-rangelow || a-rangehigh) {
+   if (rangelow || rangehigh) {
for (i = 0; i  ARRAY_SIZE(bands); i++) {
if (i == BAND_AM  !tea-has_am)
continue;
-   if (bands[i].rangelow  = a-rangelow 
-   bands[i].rangehigh = a-rangehigh)
+   if (bands[i].rangelow  = rangelow 
+   bands[i].rangehigh = rangehigh)
break;
}
if (i == ARRAY_SIZE(bands))
return -EINVAL; /* No matching band found */
 
tea-band = i;
-   if (tea-freq  a-rangelow || tea-freq  a-rangehigh) {
-   tea-freq = clamp(tea-freq, a-rangelow,
-a-rangehigh);
+   if (tea-freq  rangelow || tea-freq  rangehigh) {
+   tea-freq = clamp(tea-freq, rangelow,
+rangehigh);
res = radio_tea5777_set_freq(tea);
if (res)
return res;
}
} else {
-   a-rangelow  = bands[tea-band].rangelow;
-   a-rangehigh = bands[tea-band].rangehigh;
+   rangelow  = bands[tea-band].rangelow;
+   rangehigh = bands[tea-band].rangehigh;
}
 
spacing   = (tea-band == BAND_AM) ? (5 * 16) : (200 * 16); /* kHz */
orig_freq = tea-freq;
 
tea-write_reg |= TEA5777_W_PROGBLIM_MASK;
-   if (tea-seek_rangelow != a-rangelow) {
+   if (tea-seek_rangelow != rangelow) {
tea-write_reg = ~TEA5777_W_UPDWN_MASK;
-   tea-freq = a-rangelow;
+   tea-freq = rangelow;
res = radio_tea5777_set_freq(tea);
if (res)
goto leave;
-   tea-seek_rangelow = a-rangelow;
+   tea-seek_rangelow = rangelow;
}
-   if (tea-seek_rangehigh != a-rangehigh) {
+   if (tea-seek_rangehigh != rangehigh) {
tea-write_reg |= TEA5777_W_UPDWN_MASK;
-   tea-freq = a-rangehigh;
+   tea-freq = rangehigh;
res = radio_tea5777_set_freq(tea);
if (res)
goto leave;
-   tea-seek_rangehigh = a-rangehigh;
+   tea-seek_rangehigh = rangehigh;
}
tea-write_reg = ~TEA5777_W_PROGBLIM_MASK;
 
diff --git a/drivers/media/radio/radio-wl1273.c 
b/drivers/media/radio/radio-wl1273.c
index a22ad1c..71968a6 100644
--- a/drivers/media/radio/radio-wl1273.c
+++ b/drivers/media/radio/radio-wl1273.c
@@ -1682,7 +1682,7 @@ static int wl1273_fm_vidioc_s_frequency(struct file 
*file, void *priv,
 #define WL1273_DEFAULT_SEEK_LEVEL  7
 
 static int 

[RFCv3 API PATCH 26/31] v4l2: make vidioc_s_crop const.

2012-09-14 Thread Hans Verkuil
Write-only ioctls should have a const argument in the ioctl op.

Do this conversion for vidioc_s_crop.

Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/soc_camera/mt9m001.c |2 +-
 drivers/media/i2c/soc_camera/mt9m111.c |2 +-
 drivers/media/i2c/soc_camera/mt9t031.c |2 +-
 drivers/media/i2c/soc_camera/mt9t112.c |4 +--
 drivers/media/i2c/soc_camera/mt9v022.c |2 +-
 drivers/media/i2c/soc_camera/ov5642.c  |   20 ++--
 drivers/media/i2c/soc_camera/ov6650.c  |   32 ++--
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |4 +--
 drivers/media/i2c/tvp5150.c|2 +-
 drivers/media/pci/bt8xx/bttv-driver.c  |   10 +++---
 drivers/media/pci/cx18/cx18-ioctl.c|2 +-
 drivers/media/pci/cx25821/cx25821-video.c  |2 +-
 drivers/media/pci/cx25821/cx25821-video.h  |2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c|2 +-
 drivers/media/pci/saa7134/saa7134-video.c  |   32 ++--
 drivers/media/pci/zoran/zoran_driver.c |2 +-
 drivers/media/platform/davinci/vpbe_display.c  |2 +-
 drivers/media/platform/davinci/vpfe_capture.c  |2 +-
 drivers/media/platform/omap/omap_vout.c|2 +-
 drivers/media/platform/s5p-fimc/fimc-m2m.c |2 +-
 drivers/media/platform/s5p-g2d/g2d.c   |2 +-
 drivers/media/platform/sh_vou.c|2 +-
 .../platform/soc_camera/sh_mobile_ceu_camera.c |4 +--
 drivers/media/platform/soc_camera/soc_camera.c |6 ++--
 drivers/media/platform/vino.c  |2 +-
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c   |2 +-
 drivers/staging/media/go7007/go7007-v4l2.c |2 +-
 include/media/soc_camera.h |4 +--
 include/media/v4l2-ioctl.h |2 +-
 include/media/v4l2-subdev.h|2 +-
 30 files changed, 79 insertions(+), 79 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/mt9m001.c 
b/drivers/media/i2c/soc_camera/mt9m001.c
index d85be41..19f8a07 100644
--- a/drivers/media/i2c/soc_camera/mt9m001.c
+++ b/drivers/media/i2c/soc_camera/mt9m001.c
@@ -171,7 +171,7 @@ static int mt9m001_s_stream(struct v4l2_subdev *sd, int 
enable)
return 0;
 }
 
-static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
+static int mt9m001_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct mt9m001 *mt9m001 = to_mt9m001(client);
diff --git a/drivers/media/i2c/soc_camera/mt9m111.c 
b/drivers/media/i2c/soc_camera/mt9m111.c
index 938c5c3..62fd94a 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -383,7 +383,7 @@ static int mt9m111_reset(struct mt9m111 *mt9m111)
return ret;
 }
 
-static int mt9m111_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
+static int mt9m111_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
 {
struct v4l2_rect rect = a-c;
struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev);
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c 
b/drivers/media/i2c/soc_camera/mt9t031.c
index d74607a..40800b1 100644
--- a/drivers/media/i2c/soc_camera/mt9t031.c
+++ b/drivers/media/i2c/soc_camera/mt9t031.c
@@ -294,7 +294,7 @@ static int mt9t031_set_params(struct i2c_client *client,
return ret  0 ? ret : 0;
 }
 
-static int mt9t031_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
+static int mt9t031_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
 {
struct v4l2_rect rect = a-c;
struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/i2c/soc_camera/mt9t112.c 
b/drivers/media/i2c/soc_camera/mt9t112.c
index 9ba428e..de7cd83 100644
--- a/drivers/media/i2c/soc_camera/mt9t112.c
+++ b/drivers/media/i2c/soc_camera/mt9t112.c
@@ -907,11 +907,11 @@ static int mt9t112_g_crop(struct v4l2_subdev *sd, struct 
v4l2_crop *a)
return 0;
 }
 
-static int mt9t112_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
+static int mt9t112_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct mt9t112_priv *priv = to_mt9t112(client);
-   struct v4l2_rect *rect = a-c;
+   const struct v4l2_rect *rect = a-c;
 
return mt9t112_set_params(priv, rect, priv-format-code);
 }
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c 
b/drivers/media/i2c/soc_camera/mt9v022.c
index 350d0d8..13057b9 100644
--- a/drivers/media/i2c/soc_camera/mt9v022.c
+++ b/drivers/media/i2c/soc_camera/mt9v022.c
@@ -237,7 +237,7 @@ static int mt9v022_s_stream(struct v4l2_subdev *sd, int 

[RFCv3 API PATCH 29/31] v4l2-dev: improve ioctl validity checks.

2012-09-14 Thread Hans Verkuil
The ioctl validity checks have been improved and now take vfl_type
and vfl_dir into account.

During the 2012 Media Workshop it was decided that these improved
v4l2 core checks should be added as they simplified drivers and
made drivers behave consistently.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-dev.c   |  228 --
 drivers/media/v4l2-core/v4l2-ioctl.c |  182 +++
 2 files changed, 237 insertions(+), 173 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index 498049f..b437daa 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -551,6 +551,11 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
 {
DECLARE_BITMAP(valid_ioctls, BASE_VIDIOC_PRIVATE);
const struct v4l2_ioctl_ops *ops = vdev-ioctl_ops;
+   bool is_vid = vdev-vfl_type == VFL_TYPE_GRABBER;
+   bool is_vbi = vdev-vfl_type == VFL_TYPE_VBI;
+   bool is_radio = vdev-vfl_type == VFL_TYPE_RADIO;
+   bool is_rx = vdev-vfl_dir != VFL_DIR_TX;
+   bool is_tx = vdev-vfl_dir != VFL_DIR_RX;
 
bitmap_zero(valid_ioctls, BASE_VIDIOC_PRIVATE);
 
@@ -561,66 +566,87 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
if (ops-vidioc_s_priority ||
test_bit(V4L2_FL_USE_FH_PRIO, vdev-flags))
set_bit(_IOC_NR(VIDIOC_S_PRIORITY), valid_ioctls);
-   if (ops-vidioc_enum_fmt_vid_cap ||
-   ops-vidioc_enum_fmt_vid_out ||
-   ops-vidioc_enum_fmt_vid_cap_mplane ||
-   ops-vidioc_enum_fmt_vid_out_mplane ||
-   ops-vidioc_enum_fmt_vid_overlay)
-   set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
-   if (ops-vidioc_g_fmt_vid_cap ||
-   ops-vidioc_g_fmt_vid_out ||
-   ops-vidioc_g_fmt_vid_cap_mplane ||
-   ops-vidioc_g_fmt_vid_out_mplane ||
-   ops-vidioc_g_fmt_vid_overlay ||
-   ops-vidioc_g_fmt_vbi_cap ||
-   ops-vidioc_g_fmt_vid_out_overlay ||
-   ops-vidioc_g_fmt_vbi_out ||
-   ops-vidioc_g_fmt_sliced_vbi_cap ||
-   ops-vidioc_g_fmt_sliced_vbi_out)
-   set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
-   if (ops-vidioc_s_fmt_vid_cap ||
-   ops-vidioc_s_fmt_vid_out ||
-   ops-vidioc_s_fmt_vid_cap_mplane ||
-   ops-vidioc_s_fmt_vid_out_mplane ||
-   ops-vidioc_s_fmt_vid_overlay ||
-   ops-vidioc_s_fmt_vbi_cap ||
-   ops-vidioc_s_fmt_vid_out_overlay ||
-   ops-vidioc_s_fmt_vbi_out ||
-   ops-vidioc_s_fmt_sliced_vbi_cap ||
-   ops-vidioc_s_fmt_sliced_vbi_out)
-   set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
-   if (ops-vidioc_try_fmt_vid_cap ||
-   ops-vidioc_try_fmt_vid_out ||
-   ops-vidioc_try_fmt_vid_cap_mplane ||
-   ops-vidioc_try_fmt_vid_out_mplane ||
-   ops-vidioc_try_fmt_vid_overlay ||
-   ops-vidioc_try_fmt_vbi_cap ||
-   ops-vidioc_try_fmt_vid_out_overlay ||
-   ops-vidioc_try_fmt_vbi_out ||
-   ops-vidioc_try_fmt_sliced_vbi_cap ||
-   ops-vidioc_try_fmt_sliced_vbi_out)
-   set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
+   if (is_vid) {
+   if ((is_rx  (ops-vidioc_enum_fmt_vid_cap ||
+  ops-vidioc_enum_fmt_vid_cap_mplane ||
+  ops-vidioc_enum_fmt_vid_overlay)) ||
+   (is_tx  (ops-vidioc_enum_fmt_vid_out ||
+  ops-vidioc_enum_fmt_vid_out_mplane)))
+   set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
+   if ((is_rx  (ops-vidioc_g_fmt_vid_cap ||
+  ops-vidioc_g_fmt_vid_cap_mplane ||
+  ops-vidioc_g_fmt_vid_overlay)) ||
+   (is_tx  (ops-vidioc_g_fmt_vid_out ||
+  ops-vidioc_g_fmt_vid_out_mplane ||
+  ops-vidioc_g_fmt_vid_out_overlay)))
+set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
+   if ((is_rx  (ops-vidioc_s_fmt_vid_cap ||
+  ops-vidioc_s_fmt_vid_cap_mplane ||
+  ops-vidioc_s_fmt_vid_overlay)) ||
+   (is_tx  (ops-vidioc_s_fmt_vid_out ||
+  ops-vidioc_s_fmt_vid_out_mplane ||
+  ops-vidioc_s_fmt_vid_out_overlay)))
+set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
+   if ((is_rx  (ops-vidioc_try_fmt_vid_cap ||
+  ops-vidioc_try_fmt_vid_cap_mplane ||
+  ops-vidioc_try_fmt_vid_overlay)) ||
+   (is_tx  (ops-vidioc_try_fmt_vid_out ||
+  ops-vidioc_try_fmt_vid_out_mplane ||
+  

[RFCv3 API PATCH 31/31] Add vfl_dir field documentation.

2012-09-14 Thread Hans Verkuil
Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/v4l2-framework.txt |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Documentation/video4linux/v4l2-framework.txt 
b/Documentation/video4linux/v4l2-framework.txt
index 89318be..20f1c05 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -583,11 +583,18 @@ You should also set these fields:
 
 - name: set to something descriptive and unique.
 
+- vfl_dir: set to VFL_DIR_TX for output devices and VFL_DIR_M2M for mem2mem
+  (codec) devices.
+
 - fops: set to the v4l2_file_operations struct.
 
 - ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance
   (highly recommended to use this and it might become compulsory in the
-  future!), then set this to your v4l2_ioctl_ops struct.
+  future!), then set this to your v4l2_ioctl_ops struct. The vfl_type and
+  vfl_dir fields are used to disable ops that do not match the type/dir
+  combination. E.g. VBI ops are disabled for non-VBI nodes, and output ops
+  are disabled for a capture device. This makes it possible to provide
+  just one v4l2_ioctl_ops struct for both vbi and video nodes.
 
 - lock: leave to NULL if you want to do all the locking in the driver.
   Otherwise you give it a pointer to a struct mutex_lock and before the
-- 
1.7.10.4

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


[RFCv3 API PATCH 25/31] v4l2: make vidioc_s_modulator const.

2012-09-14 Thread Hans Verkuil
Write-only ioctls should have a const argument in the ioctl op.

Do this conversion for vidioc_s_modulator.

Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/radio/radio-keene.c   |2 +-
 drivers/media/radio/radio-si4713.c  |2 +-
 drivers/media/radio/radio-wl1273.c  |2 +-
 drivers/media/radio/si4713-i2c.c|4 ++--
 drivers/media/radio/wl128x/fmdrv_v4l2.c |2 +-
 include/media/v4l2-ioctl.h  |2 +-
 include/media/v4l2-subdev.h |2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
index 79adf3e..e10e525 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -203,7 +203,7 @@ static int vidioc_g_modulator(struct file *file, void *priv,
 }
 
 static int vidioc_s_modulator(struct file *file, void *priv,
-   struct v4l2_modulator *v)
+   const struct v4l2_modulator *v)
 {
struct keene_device *radio = video_drvdata(file);
 
diff --git a/drivers/media/radio/radio-si4713.c 
b/drivers/media/radio/radio-si4713.c
index 1e04101..a082e40 100644
--- a/drivers/media/radio/radio-si4713.c
+++ b/drivers/media/radio/radio-si4713.c
@@ -200,7 +200,7 @@ static int radio_si4713_g_modulator(struct file *file, void 
*p,
 }
 
 static int radio_si4713_s_modulator(struct file *file, void *p,
-   struct v4l2_modulator *vm)
+   const struct v4l2_modulator *vm)
 {
return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
s_modulator, vm);
diff --git a/drivers/media/radio/radio-wl1273.c 
b/drivers/media/radio/radio-wl1273.c
index 2d93354..b53ecbc 100644
--- a/drivers/media/radio/radio-wl1273.c
+++ b/drivers/media/radio/radio-wl1273.c
@@ -1715,7 +1715,7 @@ out:
 }
 
 static int wl1273_fm_vidioc_s_modulator(struct file *file, void *priv,
-   struct v4l2_modulator *modulator)
+   const struct v4l2_modulator *modulator)
 {
struct wl1273_device *radio = video_get_drvdata(video_devdata(file));
struct wl1273_core *core = radio-core;
diff --git a/drivers/media/radio/si4713-i2c.c b/drivers/media/radio/si4713-i2c.c
index b898c89..a9e6d17 100644
--- a/drivers/media/radio/si4713-i2c.c
+++ b/drivers/media/radio/si4713-i2c.c
@@ -1213,7 +1213,7 @@ exit:
 }
 
 static int si4713_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency 
*f);
-static int si4713_s_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *);
+static int si4713_s_modulator(struct v4l2_subdev *sd, const struct 
v4l2_modulator *);
 /*
  * si4713_setup - Sets the device up with current configuration.
  * @sdev: si4713_device structure for the device we are communicating
@@ -1873,7 +1873,7 @@ exit:
 }
 
 /* si4713_s_modulator - set modulator attributes */
-static int si4713_s_modulator(struct v4l2_subdev *sd, struct v4l2_modulator 
*vm)
+static int si4713_s_modulator(struct v4l2_subdev *sd, const struct 
v4l2_modulator *vm)
 {
struct si4713_device *sdev = to_si4713_device(sd);
int rval = 0;
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c 
b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index 09585a9..8a672a3 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -448,7 +448,7 @@ static int fm_v4l2_vidioc_g_modulator(struct file *file, 
void *priv,
 
 /* Set modulator attributes. If mode is not TX, set to TX. */
 static int fm_v4l2_vidioc_s_modulator(struct file *file, void *priv,
-   struct v4l2_modulator *mod)
+   const struct v4l2_modulator *mod)
 {
struct fmdev *fmdev = video_drvdata(file);
u8 rds_mode;
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index d4c7729..fbeb00e 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -179,7 +179,7 @@ struct v4l2_ioctl_ops {
int (*vidioc_g_modulator)  (struct file *file, void *fh,
struct v4l2_modulator *a);
int (*vidioc_s_modulator)  (struct file *file, void *fh,
-   struct v4l2_modulator *a);
+   const struct v4l2_modulator *a);
/* Crop ioctls */
int (*vidioc_cropcap)  (struct file *file, void *fh,
struct v4l2_cropcap *a);
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 22ab09e..e698f2c 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -194,7 +194,7 @@ struct v4l2_subdev_tuner_ops {
int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
  

[RFCv3 API PATCH 30/31] v4l2-dev: reorder checks into blocks of ioctls with similar properties.

2012-09-14 Thread Hans Verkuil
This makes it easier to read and also ties in more closely with the
profile concept.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-dev.c |  156 +---
 1 file changed, 74 insertions(+), 82 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index b437daa..a2df842 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -559,6 +559,8 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
 
bitmap_zero(valid_ioctls, BASE_VIDIOC_PRIVATE);
 
+   /* vfl_type and vfl_dir independent ioctls */
+
SET_VALID_IOCTL(ops, VIDIOC_QUERYCAP, vidioc_querycap);
if (ops-vidioc_g_priority ||
test_bit(V4L2_FL_USE_FH_PRIO, vdev-flags))
@@ -566,7 +568,49 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
if (ops-vidioc_s_priority ||
test_bit(V4L2_FL_USE_FH_PRIO, vdev-flags))
set_bit(_IOC_NR(VIDIOC_S_PRIORITY), valid_ioctls);
+   SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
+   SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
+   SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf);
+   SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf);
+   SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon);
+   SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff);
+   /* Note: the control handler can also be passed through the filehandle,
+  and that can't be tested here. If the bit for these control ioctls
+  is set, then the ioctl is valid. But if it is 0, then it can still
+  be valid if the filehandle passed the control handler. */
+   if (vdev-ctrl_handler || ops-vidioc_queryctrl)
+   set_bit(_IOC_NR(VIDIOC_QUERYCTRL), valid_ioctls);
+   if (vdev-ctrl_handler || ops-vidioc_g_ctrl || ops-vidioc_g_ext_ctrls)
+   set_bit(_IOC_NR(VIDIOC_G_CTRL), valid_ioctls);
+   if (vdev-ctrl_handler || ops-vidioc_s_ctrl || ops-vidioc_s_ext_ctrls)
+   set_bit(_IOC_NR(VIDIOC_S_CTRL), valid_ioctls);
+   if (vdev-ctrl_handler || ops-vidioc_g_ext_ctrls)
+   set_bit(_IOC_NR(VIDIOC_G_EXT_CTRLS), valid_ioctls);
+   if (vdev-ctrl_handler || ops-vidioc_s_ext_ctrls)
+   set_bit(_IOC_NR(VIDIOC_S_EXT_CTRLS), valid_ioctls);
+   if (vdev-ctrl_handler || ops-vidioc_try_ext_ctrls)
+   set_bit(_IOC_NR(VIDIOC_TRY_EXT_CTRLS), valid_ioctls);
+   if (vdev-ctrl_handler || ops-vidioc_querymenu)
+   set_bit(_IOC_NR(VIDIOC_QUERYMENU), valid_ioctls);
+   SET_VALID_IOCTL(ops, VIDIOC_G_FREQUENCY, vidioc_g_frequency);
+   SET_VALID_IOCTL(ops, VIDIOC_S_FREQUENCY, vidioc_s_frequency);
+   SET_VALID_IOCTL(ops, VIDIOC_LOG_STATUS, vidioc_log_status);
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+   SET_VALID_IOCTL(ops, VIDIOC_DBG_G_REGISTER, vidioc_g_register);
+   SET_VALID_IOCTL(ops, VIDIOC_DBG_S_REGISTER, vidioc_s_register);
+#endif
+   SET_VALID_IOCTL(ops, VIDIOC_DBG_G_CHIP_IDENT, vidioc_g_chip_ident);
+   /* yes, really vidioc_subscribe_event */
+   SET_VALID_IOCTL(ops, VIDIOC_DQEVENT, vidioc_subscribe_event);
+   SET_VALID_IOCTL(ops, VIDIOC_SUBSCRIBE_EVENT, vidioc_subscribe_event);
+   SET_VALID_IOCTL(ops, VIDIOC_UNSUBSCRIBE_EVENT, 
vidioc_unsubscribe_event);
+   SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs);
+   SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf);
+   if (ops-vidioc_enum_freq_bands || ops-vidioc_g_tuner || 
ops-vidioc_g_modulator)
+   set_bit(_IOC_NR(VIDIOC_ENUM_FREQ_BANDS), valid_ioctls);
+
if (is_vid) {
+   /* video specific ioctls */
if ((is_rx  (ops-vidioc_enum_fmt_vid_cap ||
   ops-vidioc_enum_fmt_vid_cap_mplane ||
   ops-vidioc_enum_fmt_vid_overlay)) ||
@@ -594,7 +638,20 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
   ops-vidioc_try_fmt_vid_out_mplane ||
   ops-vidioc_try_fmt_vid_out_overlay)))
 set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
+   SET_VALID_IOCTL(ops, VIDIOC_OVERLAY, vidioc_overlay);
+   SET_VALID_IOCTL(ops, VIDIOC_G_FBUF, vidioc_g_fbuf);
+   SET_VALID_IOCTL(ops, VIDIOC_S_FBUF, vidioc_s_fbuf);
+   SET_VALID_IOCTL(ops, VIDIOC_G_JPEGCOMP, vidioc_g_jpegcomp);
+   SET_VALID_IOCTL(ops, VIDIOC_S_JPEGCOMP, vidioc_s_jpegcomp);
+   SET_VALID_IOCTL(ops, VIDIOC_G_ENC_INDEX, vidioc_g_enc_index);
+   SET_VALID_IOCTL(ops, VIDIOC_ENCODER_CMD, vidioc_encoder_cmd);
+   SET_VALID_IOCTL(ops, VIDIOC_TRY_ENCODER_CMD, 
vidioc_try_encoder_cmd);
+   SET_VALID_IOCTL(ops, VIDIOC_DECODER_CMD, vidioc_decoder_cmd);
+   SET_VALID_IOCTL(ops, 

[RFCv3 API PATCH 15/31] v4l2-core: Add new V4L2_CAP_MONOTONIC_TS capability.

2012-09-14 Thread Hans Verkuil
Add a new flag that tells userspace that the monotonic clock is used
for timestamps and update the documentation accordingly.

We decided on this new flag during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 Documentation/DocBook/media/v4l/io.xml  |   10 +++---
 Documentation/DocBook/media/v4l/vidioc-dqevent.xml  |3 ++-
 Documentation/DocBook/media/v4l/vidioc-querycap.xml |7 +++
 include/linux/videodev2.h   |1 +
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 2dc39d8..b680d66 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -582,10 +582,14 @@ applications when an output stream./entry
entrystruct timeval/entry
entrystructfieldtimestamp/structfield/entry
entry/entry
-   entryparaFor input streams this is the
+   entryparaThis is either the
 system time (as returned by the functiongettimeofday()/function
-function) when the first data byte was captured. For output streams
-the data will not be displayed before this time, secondary to the
+function) or a monotonic timestamp (as returned by the
+functionclock_gettime(CLOCK_MONOTONIC, amp;ts)/function function).
+A monotonic timestamp is used if the constantV4L2_CAP_MONOTONIC_TS/constant
+capability is set, otherwise the system time is used.
+For input streams this is the timestamp when the first data byte was captured.
+For output streams the data will not be displayed before this time, secondary 
to the
 nominal frame rate determined by the current video standard in
 enqueued order. Applications can for example zero this field to
 display frames as soon as possible. The driver stores the time at
diff --git a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml 
b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
index 98a856f..00757d4 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dqevent.xml
@@ -120,7 +120,8 @@
entrystruct timespec/entry
entrystructfieldtimestamp/structfield/entry
 entry/entry
-   entryEvent timestamp./entry
+   entryEvent timestamp using the monotonic clock as returned by the
+   functionclock_gettime(CLOCK_MONOTONIC, amp;ts)/function 
function./entry
  /row
  row
entryu32/entry
diff --git a/Documentation/DocBook/media/v4l/vidioc-querycap.xml 
b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
index 4c70215..fae2036 100644
--- a/Documentation/DocBook/media/v4l/vidioc-querycap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
@@ -315,6 +315,13 @@ linkend=asyncasynchronous/link I/O methods./entry
 linkend=mmapstreaming/link I/O method./entry
  /row
  row
+   entryconstantV4L2_CAP_MONOTONIC_TS/constant/entry
+   entry0x4000/entry
+   entryThe driver uses a monotonic timestamp instead of wallclock 
time for the
+   v4l2-buffer; structfieldtimestamp/structfield field.
+   /entry
+ /row
+ row
entryconstantV4L2_CAP_DEVICE_CAPS/constant/entry
entry0x8000/entry
entryThe driver fills the structfielddevice_caps/structfield
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 292a2ef..3aad418 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -290,6 +290,7 @@ struct v4l2_capability {
 #define V4L2_CAP_ASYNCIO0x0200  /* async I/O */
 #define V4L2_CAP_STREAMING  0x0400  /* streaming I/O ioctls */
 
+#define V4L2_CAP_MONOTONIC_TS   0x4000  /* uses monotonic 
timestamps */
 #define V4L2_CAP_DEVICE_CAPS0x8000  /* sets device 
capabilities field */
 
 /*
-- 
1.7.10.4

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


[RFCv3 API PATCH 27/31] v4l2-dev: add new VFL_DIR_ defines.

2012-09-14 Thread Hans Verkuil
These will be used by v4l2-dev.c to improve ioctl checking.
I.e. ioctls for capture should return -ENOTTY when called for
an output device.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 include/media/v4l2-dev.h |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 6ee8897..95d1c91 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -26,6 +26,12 @@
 #define VFL_TYPE_SUBDEV3
 #define VFL_TYPE_MAX   4
 
+/* Is this a receiver, transmitter or mem-to-mem? */
+/* Ignored for VFL_TYPE_SUBDEV. */
+#define VFL_DIR_RX 0
+#define VFL_DIR_TX 1
+#define VFL_DIR_M2M2
+
 struct v4l2_ioctl_callbacks;
 struct video_device;
 struct v4l2_device;
@@ -105,7 +111,8 @@ struct video_device
 
/* device info */
char name[32];
-   int vfl_type;
+   int vfl_type;   /* device type */
+   int vfl_dir;/* receiver, transmitter or m2m */
/* 'minor' is set to -1 if the registration failed */
int minor;
u16 num;
-- 
1.7.10.4

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


[RFCv3 API PATCH 24/31] v4l2: make vidioc_s_audout const.

2012-09-14 Thread Hans Verkuil
Write-only ioctls should have a const argument in the ioctl op.

Do this conversion for vidioc_s_audout.

Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/pci/ivtv/ivtv-ioctl.c |6 --
 drivers/media/radio/radio-si4713.c  |2 +-
 include/media/v4l2-ioctl.h  |2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 99e35dd..d5cbb61 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -813,11 +813,13 @@ static int ivtv_g_audout(struct file *file, void *fh, 
struct v4l2_audioout *vin)
return ivtv_get_audio_output(itv, vin-index, vin);
 }
 
-static int ivtv_s_audout(struct file *file, void *fh, struct v4l2_audioout 
*vout)
+static int ivtv_s_audout(struct file *file, void *fh, const struct 
v4l2_audioout *vout)
 {
struct ivtv *itv = fh2id(fh)-itv;
 
-   return ivtv_get_audio_output(itv, vout-index, vout);
+   if (itv-card-video_outputs == NULL || vout-index != 0)
+   return -EINVAL;
+   return 0;
 }
 
 static int ivtv_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
diff --git a/drivers/media/radio/radio-si4713.c 
b/drivers/media/radio/radio-si4713.c
index 5f366d1..1e04101 100644
--- a/drivers/media/radio/radio-si4713.c
+++ b/drivers/media/radio/radio-si4713.c
@@ -83,7 +83,7 @@ static int radio_si4713_g_audout(struct file *file, void 
*priv,
 }
 
 static int radio_si4713_s_audout(struct file *file, void *priv,
-   struct v4l2_audioout *vao)
+   const struct v4l2_audioout *vao)
 {
return vao-index ? -EINVAL : 0;
 }
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index babbe09..d4c7729 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -175,7 +175,7 @@ struct v4l2_ioctl_ops {
int (*vidioc_g_audout) (struct file *file, void *fh,
struct v4l2_audioout *a);
int (*vidioc_s_audout) (struct file *file, void *fh,
-   struct v4l2_audioout *a);
+   const struct v4l2_audioout *a);
int (*vidioc_g_modulator)  (struct file *file, void *fh,
struct v4l2_modulator *a);
int (*vidioc_s_modulator)  (struct file *file, void *fh,
-- 
1.7.10.4

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


[RFCv3 API PATCH 22/31] v4l2: make vidioc_(un)subscribe_event const.

2012-09-14 Thread Hans Verkuil
Write-only ioctls should have a const argument in the ioctl op.

Do this conversion for vidioc_(un)subscribe_event.

Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/pci/ivtv/ivtv-ioctl.c   |2 +-
 drivers/media/platform/omap3isp/ispccdc.c |4 ++--
 drivers/media/platform/omap3isp/ispstat.c |4 ++--
 drivers/media/platform/omap3isp/ispstat.h |4 ++--
 drivers/media/v4l2-core/v4l2-ctrls.c  |2 +-
 drivers/media/v4l2-core/v4l2-event.c  |4 ++--
 include/media/v4l2-ctrls.h|2 +-
 include/media/v4l2-event.h|4 ++--
 include/media/v4l2-ioctl.h|4 ++--
 9 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index d3b32c2..966abb4 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -1460,7 +1460,7 @@ static int ivtv_overlay(struct file *file, void *fh, 
unsigned int on)
return 0;
 }
 
-static int ivtv_subscribe_event(struct v4l2_fh *fh, struct 
v4l2_event_subscription *sub)
+static int ivtv_subscribe_event(struct v4l2_fh *fh, const struct 
v4l2_event_subscription *sub)
 {
switch (sub-type) {
case V4L2_EVENT_VSYNC:
diff --git a/drivers/media/platform/omap3isp/ispccdc.c 
b/drivers/media/platform/omap3isp/ispccdc.c
index aa9df9d..60181ab 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -1706,7 +1706,7 @@ static long ccdc_ioctl(struct v4l2_subdev *sd, unsigned 
int cmd, void *arg)
 }
 
 static int ccdc_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
-   struct v4l2_event_subscription *sub)
+   const struct v4l2_event_subscription *sub)
 {
if (sub-type != V4L2_EVENT_FRAME_SYNC)
return -EINVAL;
@@ -1719,7 +1719,7 @@ static int ccdc_subscribe_event(struct v4l2_subdev *sd, 
struct v4l2_fh *fh,
 }
 
 static int ccdc_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub)
+ const struct v4l2_event_subscription *sub)
 {
return v4l2_event_unsubscribe(fh, sub);
 }
diff --git a/drivers/media/platform/omap3isp/ispstat.c 
b/drivers/media/platform/omap3isp/ispstat.c
index b8640be..d7ac76b 100644
--- a/drivers/media/platform/omap3isp/ispstat.c
+++ b/drivers/media/platform/omap3isp/ispstat.c
@@ -1025,7 +1025,7 @@ void omap3isp_stat_dma_isr(struct ispstat *stat)
 
 int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
  struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub)
+ const struct v4l2_event_subscription *sub)
 {
struct ispstat *stat = v4l2_get_subdevdata(subdev);
 
@@ -1037,7 +1037,7 @@ int omap3isp_stat_subscribe_event(struct v4l2_subdev 
*subdev,
 
 int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
struct v4l2_fh *fh,
-   struct v4l2_event_subscription *sub)
+   const struct v4l2_event_subscription *sub)
 {
return v4l2_event_unsubscribe(fh, sub);
 }
diff --git a/drivers/media/platform/omap3isp/ispstat.h 
b/drivers/media/platform/omap3isp/ispstat.h
index 9b7c865..a6fe653 100644
--- a/drivers/media/platform/omap3isp/ispstat.h
+++ b/drivers/media/platform/omap3isp/ispstat.h
@@ -147,10 +147,10 @@ int omap3isp_stat_init(struct ispstat *stat, const char 
*name,
 void omap3isp_stat_cleanup(struct ispstat *stat);
 int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
  struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub);
+ const struct v4l2_event_subscription *sub);
 int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
struct v4l2_fh *fh,
-   struct v4l2_event_subscription *sub);
+   const struct v4l2_event_subscription *sub);
 int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
 
 int omap3isp_stat_busy(struct ispstat *stat);
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index ab287f2..f400035 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -2699,7 +2699,7 @@ int v4l2_ctrl_log_status(struct file *file, void *fh)
 EXPORT_SYMBOL(v4l2_ctrl_log_status);
 
 int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
-   struct v4l2_event_subscription *sub)
+   const struct v4l2_event_subscription *sub)
 {
if (sub-type == 

[RFCv3 API PATCH 17/31] DocBook: clarify that sequence is also set for output devices.

2012-09-14 Thread Hans Verkuil
It was not entirely obvious that the sequence count should also
be set for output devices. Also made it more explicit that this
sequence counter counts frames, not fields.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/DocBook/media/v4l/io.xml |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index b680d66..c32cb0a 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -617,8 +617,8 @@ field is independent of the 
structfieldtimestamp/structfield and
entry__u32/entry
entrystructfieldsequence/structfield/entry
entry/entry
-   entrySet by the driver, counting the frames in the
-sequence./entry
+   entrySet by the driver, counting the frames (not fields!) in
+sequence. This field is set for both input and output devices./entry
  /row
  row
entry spanname=hspanparaIn link
-- 
1.7.10.4

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


[RFCv3 API PATCH 20/31] v4l2: make vidioc_s_jpegcomp const.

2012-09-14 Thread Hans Verkuil
Write-only ioctls should have a const argument in the ioctl op.

Do this conversion for vidioc_s_jpegcomp.

Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/pci/zoran/zoran_driver.c |4 ++--
 drivers/media/usb/cpia2/cpia2_v4l.c|5 ++---
 drivers/media/usb/gspca/gspca.c|2 +-
 drivers/media/usb/gspca/gspca.h|8 +---
 drivers/media/usb/gspca/jeilinj.c  |2 +-
 drivers/media/usb/gspca/ov519.c|2 +-
 drivers/media/usb/gspca/topro.c|2 +-
 drivers/media/usb/gspca/zc3xx.c|9 ++---
 drivers/media/usb/s2255/s2255drv.c |2 +-
 drivers/media/v4l2-core/v4l2-ioctl.c   |2 ++
 drivers/staging/media/go7007/go7007-v4l2.c |2 +-
 include/media/v4l2-ioctl.h |2 +-
 12 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/media/pci/zoran/zoran_driver.c 
b/drivers/media/pci/zoran/zoran_driver.c
index f91b551..9ecd7d7 100644
--- a/drivers/media/pci/zoran/zoran_driver.c
+++ b/drivers/media/pci/zoran/zoran_driver.c
@@ -2674,7 +2674,7 @@ static int zoran_g_jpegcomp(struct file *file, void *__fh,
 }
 
 static int zoran_s_jpegcomp(struct file *file, void *__fh,
-   struct v4l2_jpegcompression *params)
+   const struct v4l2_jpegcompression 
*params)
 {
struct zoran_fh *fh = __fh;
struct zoran *zr = fh-zr;
@@ -2701,7 +2701,7 @@ static int zoran_s_jpegcomp(struct file *file, void *__fh,
if (!fh-buffers.allocated)
fh-buffers.buffer_size =
zoran_v4l2_calc_bufsize(fh-jpg_settings);
-   fh-jpg_settings.jpg_comp = *params = settings.jpg_comp;
+   fh-jpg_settings.jpg_comp = settings.jpg_comp;
 sjpegc_unlock_and_return:
mutex_unlock(zr-resource_lock);
 
diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c 
b/drivers/media/usb/cpia2/cpia2_v4l.c
index 5ca6f44..aeb9d22 100644
--- a/drivers/media/usb/cpia2/cpia2_v4l.c
+++ b/drivers/media/usb/cpia2/cpia2_v4l.c
@@ -734,7 +734,8 @@ static int cpia2_g_jpegcomp(struct file *file, void *fh, 
struct v4l2_jpegcompres
  *
  */
 
-static int cpia2_s_jpegcomp(struct file *file, void *fh, struct 
v4l2_jpegcompression *parms)
+static int cpia2_s_jpegcomp(struct file *file, void *fh,
+   const struct v4l2_jpegcompression *parms)
 {
struct camera_data *cam = video_drvdata(file);
 
@@ -743,8 +744,6 @@ static int cpia2_s_jpegcomp(struct file *file, void *fh, 
struct v4l2_jpegcompres
 
cam-params.compression.inhibit_htables =
!(parms-jpeg_markers  V4L2_JPEG_MARKER_DHT);
-   parms-jpeg_markers = V4L2_JPEG_MARKER_DQT | V4L2_JPEG_MARKER_DRI |
-  V4L2_JPEG_MARKER_DHT;
 
if(parms-APP_len != 0) {
if(parms-APP_len  0 
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 98b91a2..521b508 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -1687,7 +1687,7 @@ static int vidioc_g_jpegcomp(struct file *file, void 
*priv,
 }
 
 static int vidioc_s_jpegcomp(struct file *file, void *priv,
-   struct v4l2_jpegcompression *jpegcomp)
+   const struct v4l2_jpegcompression *jpegcomp)
 {
struct gspca_dev *gspca_dev = video_drvdata(file);
 
diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h
index dc688c7..e3eab82 100644
--- a/drivers/media/usb/gspca/gspca.h
+++ b/drivers/media/usb/gspca/gspca.h
@@ -83,8 +83,10 @@ struct gspca_frame;
 typedef int (*cam_op) (struct gspca_dev *);
 typedef void (*cam_v_op) (struct gspca_dev *);
 typedef int (*cam_cf_op) (struct gspca_dev *, const struct usb_device_id *);
-typedef int (*cam_jpg_op) (struct gspca_dev *,
+typedef int (*cam_get_jpg_op) (struct gspca_dev *,
struct v4l2_jpegcompression *);
+typedef int (*cam_set_jpg_op) (struct gspca_dev *,
+   const struct v4l2_jpegcompression *);
 typedef int (*cam_reg_op) (struct gspca_dev *,
struct v4l2_dbg_register *);
 typedef int (*cam_ident_op) (struct gspca_dev *,
@@ -126,8 +128,8 @@ struct sd_desc {
cam_v_op stopN; /* called on stream off - main alt */
cam_v_op stop0; /* called on stream off  disconnect - alt 0 */
cam_v_op dq_callback;   /* called when a frame has been dequeued */
-   cam_jpg_op get_jcomp;
-   cam_jpg_op set_jcomp;
+   cam_get_jpg_op get_jcomp;
+   cam_set_jpg_op set_jcomp;
cam_qmnu_op querymenu;
cam_streamparm_op get_streamparm;
cam_streamparm_op set_streamparm;
diff --git a/drivers/media/usb/gspca/jeilinj.c 

[RFCv3 API PATCH 06/31] vivi/mem2mem_testdev: update to latest bus_info specification.

2012-09-14 Thread Hans Verkuil
Prefix bus_info with platform:.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/mem2mem_testdev.c |3 ++-
 drivers/media/platform/vivi.c|3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index 0b496f3..74de642 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -430,7 +430,8 @@ static int vidioc_querycap(struct file *file, void *priv,
 {
strncpy(cap-driver, MEM2MEM_NAME, sizeof(cap-driver) - 1);
strncpy(cap-card, MEM2MEM_NAME, sizeof(cap-card) - 1);
-   strlcpy(cap-bus_info, MEM2MEM_NAME, sizeof(cap-bus_info));
+   snprintf(cap-bus_info, sizeof(cap-bus_info),
+   platform:%s, MEM2MEM_NAME);
cap-device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index a6351c4..7f3e6329 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -898,7 +898,8 @@ static int vidioc_querycap(struct file *file, void  *priv,
 
strcpy(cap-driver, vivi);
strcpy(cap-card, vivi);
-   strlcpy(cap-bus_info, dev-v4l2_dev.name, sizeof(cap-bus_info));
+   snprintf(cap-bus_info, sizeof(cap-bus_info),
+   platform:%s, dev-v4l2_dev.name);
cap-device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
V4L2_CAP_READWRITE;
cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
-- 
1.7.10.4

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


[RFCv3 API PATCH 12/31] Rename V4L2_(IN|OUT)_CAP_CUSTOM_TIMINGS.

2012-09-14 Thread Hans Verkuil
The 'custom' timings are no longer just for custom timings, but also for 
standard
CEA/VESA timings. So rename to V4L2_IN/OUT_CAP_DV_TIMINGS.

The old define is still kept for backwards compatibility.

This decision was taken during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/vidioc-enuminput.xml|2 +-
 Documentation/DocBook/media/v4l/vidioc-enumoutput.xml   |2 +-
 Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml |2 +-
 drivers/media/v4l2-core/v4l2-ioctl.c|8 
 include/linux/videodev2.h   |6 --
 5 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-enuminput.xml 
b/Documentation/DocBook/media/v4l/vidioc-enuminput.xml
index 46d5a04..3c9a813 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enuminput.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enuminput.xml
@@ -283,7 +283,7 @@ input/output interface to linux-media@vger.kernel.org on 19 
Oct 2009.
entryThis input supports setting DV presets by using 
VIDIOC_S_DV_PRESET./entry
  /row
  row
-   entryconstantV4L2_IN_CAP_CUSTOM_TIMINGS/constant/entry
+   entryconstantV4L2_IN_CAP_DV_TIMINGS/constant/entry
entry0x0002/entry
entryThis input supports setting video timings by using 
VIDIOC_S_DV_TIMINGS./entry
  /row
diff --git a/Documentation/DocBook/media/v4l/vidioc-enumoutput.xml 
b/Documentation/DocBook/media/v4l/vidioc-enumoutput.xml
index 4280200..f4ab079 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enumoutput.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enumoutput.xml
@@ -168,7 +168,7 @@ input/output interface to linux-media@vger.kernel.org on 19 
Oct 2009.
entryThis output supports setting DV presets by using 
VIDIOC_S_DV_PRESET./entry
  /row
  row
-   entryconstantV4L2_OUT_CAP_CUSTOM_TIMINGS/constant/entry
+   entryconstantV4L2_OUT_CAP_DV_TIMINGS/constant/entry
entry0x0002/entry
entryThis output supports setting video timings by using 
VIDIOC_S_DV_TIMINGS./entry
  /row
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml
index feaa180..7236970 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-dv-timings.xml
@@ -57,7 +57,7 @@ or the timing values are not correct, the driver returns 
EINVAL;./para
 paraThe filenamelinux/v4l2-dv-timings.h/filename header can be used to 
get the
 timings of the formats in the xref linkend=cea861 / and xref 
linkend=vesadmt /
 standards. If the current input or output does not support DV timings (e.g. if
-VIDIOC-ENUMINPUT; does not set the 
constantV4L2_IN_CAP_CUSTOM_TIMINGS/constant flag), then
+VIDIOC-ENUMINPUT; does not set the 
constantV4L2_IN_CAP_DV_TIMINGS/constant flag), then
 ENODATA; is returned./para
   /refsect1
 
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 4ee9158..8de792c 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -982,7 +982,7 @@ static int v4l_enuminput(const struct v4l2_ioctl_ops *ops,
struct v4l2_input *p = arg;
 
/*
-* We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS 
+* We set the flags for CAP_PRESETS, CAP_DV_TIMINGS 
 * CAP_STD here based on ioctl handler provided by the
 * driver. If the driver doesn't support these
 * for a specific input, it must override these flags.
@@ -992,7 +992,7 @@ static int v4l_enuminput(const struct v4l2_ioctl_ops *ops,
if (ops-vidioc_s_dv_preset)
p-capabilities |= V4L2_IN_CAP_PRESETS;
if (ops-vidioc_s_dv_timings)
-   p-capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS;
+   p-capabilities |= V4L2_IN_CAP_DV_TIMINGS;
 
return ops-vidioc_enum_input(file, fh, p);
 }
@@ -1003,7 +1003,7 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops 
*ops,
struct v4l2_output *p = arg;
 
/*
-* We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS 
+* We set the flags for CAP_PRESETS, CAP_DV_TIMINGS 
 * CAP_STD here based on ioctl handler provided by the
 * driver. If the driver doesn't support these
 * for a specific output, it must override these flags.
@@ -1013,7 +1013,7 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops 
*ops,
if (ops-vidioc_s_dv_preset)
p-capabilities |= V4L2_OUT_CAP_PRESETS;
if (ops-vidioc_s_dv_timings)
-   p-capabilities |= V4L2_OUT_CAP_CUSTOM_TIMINGS;
+   p-capabilities |= V4L2_OUT_CAP_DV_TIMINGS;
 
return ops-vidioc_enum_output(file, fh, p);
 }
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h

[RFCv3 API PATCH 16/31] Add V4L2_CAP_MONOTONIC_TS where applicable.

2012-09-14 Thread Hans Verkuil
Add the new V4L2_CAP_MONOTONIC_TS capability to those drivers that
use monotomic timestamps instead of the system time.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/pci/cx18/cx18-ioctl.c   |2 +-
 drivers/media/platform/davinci/vpbe_display.c |3 ++-
 drivers/media/platform/omap3isp/ispvideo.c|5 +++--
 drivers/media/platform/s5p-fimc/fimc-lite.c   |2 +-
 drivers/media/usb/gspca/gspca.c   |1 +
 drivers/media/usb/uvc/uvc_v4l2.c  |7 +++
 6 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-ioctl.c 
b/drivers/media/pci/cx18/cx18-ioctl.c
index e9912db..51675bc 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -473,7 +473,7 @@ static int cx18_querycap(struct file *file, void *fh,
 PCI:%s, pci_name(cx-pci_dev));
vcap-capabilities = cx-v4l2_cap;  /* capabilities */
if (id-type == CX18_ENC_STREAM_TYPE_YUV)
-   vcap-capabilities |= V4L2_CAP_STREAMING;
+   vcap-capabilities |= V4L2_CAP_STREAMING | 
V4L2_CAP_MONOTONIC_TS;
return 0;
 }
 
diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index 9a05c81..a529e28 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -620,7 +620,8 @@ static int vpbe_display_querycap(struct file *file, void  
*priv,
struct vpbe_device *vpbe_dev = fh-disp_dev-vpbe_dev;
 
cap-version = VPBE_DISPLAY_VERSION_CODE;
-   cap-capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
+   cap-capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING |
+   V4L2_CAP_MONOTONIC_TS;
strlcpy(cap-driver, VPBE_DISPLAY_DRIVER, sizeof(cap-driver));
strlcpy(cap-bus_info, platform, sizeof(cap-bus_info));
strlcpy(cap-card, vpbe_dev-cfg-module_name, sizeof(cap-card));
diff --git a/drivers/media/platform/omap3isp/ispvideo.c 
b/drivers/media/platform/omap3isp/ispvideo.c
index 3a5085e..a25aa1d 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -663,10 +663,11 @@ isp_video_querycap(struct file *file, void *fh, struct 
v4l2_capability *cap)
strlcpy(cap-card, video-video.name, sizeof(cap-card));
strlcpy(cap-bus_info, media, sizeof(cap-bus_info));
 
+   cap-capabilities = V4L2_CAP_STREAMING | V4L2_CAP_MONOTONIC_TS;
if (video-type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-   cap-capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
+   cap-capabilities |= V4L2_CAP_VIDEO_CAPTURE;
else
-   cap-capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
+   cap-capabilities |= V4L2_CAP_VIDEO_OUTPUT;
 
return 0;
 }
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index c5b57e8..ab12928 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -629,7 +629,7 @@ static int fimc_vidioc_querycap_capture(struct file *file, 
void *priv,
strlcpy(cap-driver, FIMC_LITE_DRV_NAME, sizeof(cap-driver));
cap-bus_info[0] = 0;
cap-card[0] = 0;
-   cap-capabilities = V4L2_CAP_STREAMING;
+   cap-capabilities = V4L2_CAP_STREAMING | V4L2_CAP_MONOTONIC_TS;
return 0;
 }
 
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 2abbf52..98b91a2 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -1351,6 +1351,7 @@ static int vidioc_querycap(struct file *file, void  *priv,
usb_make_path(gspca_dev-dev, (char *) cap-bus_info,
sizeof(cap-bus_info));
cap-device_caps = V4L2_CAP_VIDEO_CAPTURE
+ | V4L2_CAP_MONOTONIC_TS
  | V4L2_CAP_STREAMING
  | V4L2_CAP_READWRITE;
cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index f00db30..1c6dff0 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -564,12 +564,11 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned 
int cmd, void *arg)
usb_make_path(stream-dev-udev,
  cap-bus_info, sizeof(cap-bus_info));
cap-version = LINUX_VERSION_CODE;
+   cap-capabilities = V4L2_CAP_STREAMING | V4L2_CAP_MONOTONIC_TS;
if (stream-type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-   cap-capabilities = V4L2_CAP_VIDEO_CAPTURE
- | V4L2_CAP_STREAMING;
+   

[RFCv3 API PATCH 14/31] DocBook: fix awkward language and fix the documented return value.

2012-09-14 Thread Hans Verkuil
The Video Standard section contains some awkward language. It also wasn't
updated when the error code for unimplemented ioctls changed from EINVAL
to ENOTTY.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/common.xml |   30 +---
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/common.xml 
b/Documentation/DocBook/media/v4l/common.xml
index b91d253..08db1cf 100644
--- a/Documentation/DocBook/media/v4l/common.xml
+++ b/Documentation/DocBook/media/v4l/common.xml
@@ -564,7 +564,7 @@ automatically./para
 paraTo query and select the standard used by the current video
 input or output applications call the VIDIOC-G-STD; and
 VIDIOC-S-STD; ioctl, respectively. The emphasisreceived/emphasis
-standard can be sensed with the VIDIOC-QUERYSTD; ioctl. Note parameter of all 
these ioctls is a pointer to a v4l2-std-id; type (a standard set), 
emphasisnot/emphasis an index into the standard enumeration.footnote
+standard can be sensed with the VIDIOC-QUERYSTD; ioctl. Note that the 
parameter of all these ioctls is a pointer to a v4l2-std-id; type (a standard 
set), emphasisnot/emphasis an index into the standard enumeration.footnote
paraAn alternative to the current scheme is to use pointers
 to indices as arguments of constantVIDIOC_G_STD/constant and
 constantVIDIOC_S_STD/constant, the v4l2-input; and
@@ -588,30 +588,28 @@ switch to a standard by v4l2-std-id;./para
   /footnote Drivers must implement all video standard ioctls
 when the device has one or more video inputs or outputs./para
 
-paraSpecial rules apply to USB cameras where the notion of video
-standards makes little sense. More generally any capture device,
-output devices accordingly, which is itemizedlist
+paraSpecial rules apply to devices such as USB cameras where the notion 
of video
+standards makes little sense. More generally for any capture or output device
+which is: itemizedlist
listitem
  paraincapable of capturing fields or frames at the nominal
 rate of the video standard, or/para
/listitem
listitem
- parawhere link linkend=buffertimestamps/link refer
-to the instant the field or frame was received by the driver, not the
-capture time, or/para
-   /listitem
-   listitem
- parawhere link linkend=buffersequence numbers/link
-refer to the frames received by the driver, not the captured
-frames./para
+ parathat does not support the video standard formats at all./para
/listitem
   /itemizedlist Here the driver shall set the
 structfieldstd/structfield field of v4l2-input; and v4l2-output;
-to zero, the constantVIDIOC_G_STD/constant,
+to zero and the constantVIDIOC_G_STD/constant,
 constantVIDIOC_S_STD/constant,
 constantVIDIOC_QUERYSTD/constant and
 constantVIDIOC_ENUMSTD/constant ioctls shall return the
-EINVAL;.footnote
+ENOTTY;.footnote
+   paraSee xref linkend=buffer / for a rationale./para
+   paraApplications can make use of the xref 
linkend=input-capabilities / and
+xref linkend=output-capabilities/ flags to determine whether the video 
standard ioctls
+are available for the device./para
+ENOTTY;.footnote
paraSee xref linkend=buffer / for a rationale. Probably
 even USB cameras follow some well known video standard. It might have
 been better to explicitly indicate elsewhere if a device cannot live
@@ -626,9 +624,9 @@ up to normal expectations, instead of this exception./para
 v4l2-standard; standard;
 
 if (-1 == ioctl (fd, VIDIOC-G-STD;, amp;std_id)) {
-   /* Note when VIDIOC_ENUMSTD always returns EINVAL this
+   /* Note when VIDIOC_ENUMSTD always returns ENOTTY this
   is no video device or it falls under the USB exception,
-  and VIDIOC_G_STD returning EINVAL is no error. */
+  and VIDIOC_G_STD returning ENOTTY is no error. */
 
perror (VIDIOC_G_STD);
exit (EXIT_FAILURE);
-- 
1.7.10.4

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


[RFCv3 API PATCH 18/31] DocBook: Mark CROPCAP as optional instead of as compulsory.

2012-09-14 Thread Hans Verkuil
While the documentation says that VIDIOC_CROPCAP is compulsory for
all video capture and output devices, in practice VIDIOC_CROPCAP is
only implemented for devices that can do cropping and/or scaling.

Update the documentation to no longer require VIDIOC_CROPCAP if the
driver does not support cropping or scaling or non-square pixels.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/vidioc-cropcap.xml |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-cropcap.xml 
b/Documentation/DocBook/media/v4l/vidioc-cropcap.xml
index 4559c45..bf7cc97 100644
--- a/Documentation/DocBook/media/v4l/vidioc-cropcap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-cropcap.xml
@@ -59,6 +59,9 @@ constant except when switching the video standard. Remember 
this
 switch can occur implicit when switching the video input or
 output./para
 
+paraThis ioctl must be implemented for video capture or output devices 
that
+support cropping and/or scaling and/or have non-square pixels, and for overlay 
devices./para
+
 table pgwide=1 frame=none id=v4l2-cropcap
   titlestruct structnamev4l2_cropcap/structname/title
   tgroup cols=3
@@ -70,7 +73,9 @@ output./para
entryType of the data stream, set by the application.
 Only these types are valid here:
 constantV4L2_BUF_TYPE_VIDEO_CAPTURE/constant,
-constantV4L2_BUF_TYPE_VIDEO_OUTPUT/constant and
+constantV4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE/constant,
+constantV4L2_BUF_TYPE_VIDEO_OUTPUT/constant,
+constantV4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE/constant and
 constantV4L2_BUF_TYPE_VIDEO_OVERLAY/constant. See xref 
linkend=v4l2-buf-type /./entry
  /row
  row
@@ -154,8 +159,7 @@ on 22 Oct 2002 subject Re:[V4L][patches!] 
Re:v4l2/kernel-2.5 --
termerrorcodeEINVAL/errorcode/term
listitem
  paraThe v4l2-cropcap; structfieldtype/structfield is
-invalid. This is not permitted for video capture, output and overlay devices,
-which must support constantVIDIOC_CROPCAP/constant./para
+invalid./para
/listitem
   /varlistentry
 /variablelist
-- 
1.7.10.4

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


[RFCv1 API PATCH 4/4] tuner-core: map audmode to STEREO for radio devices.

2012-09-14 Thread Hans Verkuil
Fixes a v4l2-compliance error: setting audmode to a value other than mono
or stereo for a radio device should map to MODE_STEREO.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/tuner-core.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/tuner-core.c 
b/drivers/media/v4l2-core/tuner-core.c
index b5a819a..ea71371 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -1235,8 +1235,11 @@ static int tuner_s_tuner(struct v4l2_subdev *sd, struct 
v4l2_tuner *vt)
if (set_mode(t, vt-type))
return 0;
 
-   if (t-mode == V4L2_TUNER_RADIO)
+   if (t-mode == V4L2_TUNER_RADIO) {
t-audmode = vt-audmode;
+   if (t-audmode  V4L2_TUNER_MODE_STEREO)
+   t-audmode = V4L2_TUNER_MODE_STEREO;
+   }
set_freq(t, 0);
 
return 0;
-- 
1.7.10.4

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


[RFCv1 API PATCH 1/4] vb2: fix wrong owner check

2012-09-14 Thread Hans Verkuil
Check against q-fileio to see if the queue owner should be set or not.
The former check against the return value of read or write is wrong, since
read/write can return an error, even if the queue is in streaming mode.
For example, EAGAIN when in non-blocking mode.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/videobuf2-core.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 4da3df6..59ed522 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2278,7 +2278,7 @@ ssize_t vb2_fop_write(struct file *file, char __user *buf,
goto exit;
err = vb2_write(vdev-queue, buf, count, ppos,
   file-f_flags  O_NONBLOCK);
-   if (err = 0)
+   if (vdev-queue-fileio)
vdev-queue-owner = file-private_data;
 exit:
if (lock)
@@ -2300,7 +2300,7 @@ ssize_t vb2_fop_read(struct file *file, char __user *buf,
goto exit;
err = vb2_read(vdev-queue, buf, count, ppos,
   file-f_flags  O_NONBLOCK);
-   if (err = 0)
+   if (vdev-queue-fileio)
vdev-queue-owner = file-private_data;
 exit:
if (lock)
-- 
1.7.10.4

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


[RFCv1 API PATCH 1/4] Two fixes and two v4l2-ctrl enhancements

2012-09-14 Thread Hans Verkuil
Hi all,

The first and last patches are bug fixes, and the second and third add
two new features to the control framework:

The first new feature adds a notifier to a control. When set the notifier
will be called whenever the control changes value. This feature is needed
to allow bridge drivers to detect changes in controls of a subdevice,
even if those controls are private to the subdevice. It does for kernel
drivers what the V4L2 event API does for userspace.

This functionality is initially required for the em28xx conversion to
the control framework, but it is also required for drivers that have to
deal with e.g. HDMI connectors with all the hotplug etc. events.

The second feature adds a filter function to the v4l2_ctrl_add_handler
function that allows you to select more precisely which controls you
want to add.

The primary purpose is to add only the audio controls to a control handler
for a radio device. Currently you will also see the video controls when
listing controls from the radio device of a combine tv/radio card and with
this filter function it is easy to fix that.

Comments are welcome!

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


[RFCv1 API PATCH 2/4] v4l2-ctrls: add a notify callback.

2012-09-14 Thread Hans Verkuil
Sometimes platform/bridge drivers need to be notified when a control from
a subdevice changes value. In order to support this a notify callback was
added.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/v4l2-controls.txt |   22 ++
 drivers/media/v4l2-core/v4l2-ctrls.c|   25 +
 include/media/v4l2-ctrls.h  |   25 +
 3 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/Documentation/video4linux/v4l2-controls.txt 
b/Documentation/video4linux/v4l2-controls.txt
index 43da22b..cecaff8 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -687,14 +687,20 @@ a control of this type whenever the first control 
belonging to a new control
 class is added.
 
 
-Proposals for Extensions
-
+Adding Notify Callbacks
+===
+
+Sometimes the platform or bridge driver needs to be notified when a control
+from a sub-device driver changes. You can set a notify callback by calling
+this function:
 
-Some ideas for future extensions to the spec:
+void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl,
+   void (*notify)(struct v4l2_ctrl *ctrl, void *priv), void *priv);
 
-1) Add a V4L2_CTRL_FLAG_HEX to have values shown as hexadecimal instead of
-decimal. Useful for e.g. video_mute_yuv.
+Whenever the give control changes value the notify callback will be called
+with a pointer to the control and the priv pointer that was passed with
+v4l2_ctrl_notify. Note that the control's handler lock is held when the
+notify function is called.
 
-2) It is possible to mark in the controls array which controls have been
-successfully written and which failed by for example adding a bit to the
-control ID. Not sure if it is worth the effort, though.
+There can be only one notify function per control handler. Any attempt
+to set another notify function will cause a WARN_ON.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index f400035..43061e1 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1160,6 +1160,8 @@ static void new_to_cur(struct v4l2_fh *fh, struct 
v4l2_ctrl *ctrl,
send_event(fh, ctrl,
(changed ? V4L2_EVENT_CTRL_CH_VALUE : 0) |
(update_inactive ? V4L2_EVENT_CTRL_CH_FLAGS : 0));
+   if (ctrl-call_notify  changed  ctrl-handler-notify)
+   ctrl-handler-notify(ctrl, ctrl-handler-notify_priv);
}
 }
 
@@ -2628,6 +2630,29 @@ int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 
val)
 }
 EXPORT_SYMBOL(v4l2_ctrl_s_ctrl_int64);
 
+void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, 
void *priv)
+{
+   if (ctrl == NULL)
+   return;
+   if (notify == NULL) {
+   ctrl-call_notify = 0;
+   return;
+   }
+   /* Only one notifier is allowed. Should we ever need to support
+  multiple notifiers, then some sort of linked list of notifiers
+  should be implemented. But I don't see any real reason to implement
+  that now. If you think you need multiple notifiers, then contact
+  the linux-media mailinglist. */
+   if (WARN_ON(ctrl-handler-notify 
+   (ctrl-handler-notify != notify ||
+ctrl-handler-notify_priv != priv)))
+   return;
+   ctrl-handler-notify = notify;
+   ctrl-handler-notify_priv = priv;
+   ctrl-call_notify = 1;
+}
+EXPORT_SYMBOL(v4l2_ctrl_notify);
+
 static int v4l2_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned 
elems)
 {
struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev-fh-ctrl_handler, sev-id);
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 6890f5e..4484fd3 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -53,6 +53,8 @@ struct v4l2_ctrl_ops {
int (*s_ctrl)(struct v4l2_ctrl *ctrl);
 };
 
+typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
+
 /** struct v4l2_ctrl - The control structure.
   * @node: The list node.
   * @ev_subs:  The list of control event subscriptions.
@@ -72,6 +74,8 @@ struct v4l2_ctrl_ops {
   *set this flag directly.
   * @has_volatiles: If set, then one or more members of the cluster are 
volatile.
   *Drivers should never touch this flag.
+  * @call_notify: If set, then call the handler's notify function whenever the
+  *control's value changes.
   * @manual_mode_value: If the is_auto flag is set, then this is the value
   *of the auto control that determines if that control is in
   *manual mode. So if the value of the auto control equals this
@@ -119,6 +123,7 @@ struct v4l2_ctrl {
unsigned int is_private:1;
unsigned int is_auto:1;

[RFCv1 API PATCH 3/4] v4l2-ctrls: add a filter function to v4l2_ctrl_add_handler.

2012-09-14 Thread Hans Verkuil
With a filter function you can control more precisely which controls
are added. This is useful in particular for radio device nodes for
combined TV/Radio cards where you want to show just the radio-specific
controls and not controls like brightness.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/video4linux/v4l2-controls.txt|6 +-
 drivers/media/pci/cx88/cx88-blackbird.c|2 +-
 drivers/media/pci/cx88/cx88-video.c|2 +-
 drivers/media/platform/s5p-fimc/fimc-capture.c |2 +-
 drivers/media/platform/soc_camera/soc_camera.c |2 +-
 drivers/media/v4l2-core/v4l2-ctrls.c   |   25 +++-
 drivers/media/v4l2-core/v4l2-device.c  |2 +-
 include/media/v4l2-ctrls.h |   18 +++--
 8 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/Documentation/video4linux/v4l2-controls.txt 
b/Documentation/video4linux/v4l2-controls.txt
index cecaff8..cd4a26c 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -594,7 +594,11 @@ handler and finally add the first handler to the second. 
For example:
v4l2_ctrl_new_std(radio_ctrl_handler, radio_ops, V4L2_CID_AUDIO_MUTE, 
...);
v4l2_ctrl_new_std(video_ctrl_handler, video_ops, V4L2_CID_BRIGHTNESS, 
...);
v4l2_ctrl_new_std(video_ctrl_handler, video_ops, V4L2_CID_CONTRAST, 
...);
-   v4l2_ctrl_add_handler(video_ctrl_handler, radio_ctrl_handler);
+   v4l2_ctrl_add_handler(video_ctrl_handler, radio_ctrl_handler, NULL);
+
+The last argument to v4l2_ctrl_add_handler() is a filter function that allows
+you to filter which controls will be added. Set it to NULL if you want to add
+all controls.
 
 Or you can add specific controls to a handler:
 
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c 
b/drivers/media/pci/cx88/cx88-blackbird.c
index 843ffd9..def363f 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -1236,7 +1236,7 @@ static int cx8802_blackbird_probe(struct cx8802_driver 
*drv)
err = cx2341x_handler_init(dev-cxhdl, 36);
if (err)
goto fail_core;
-   v4l2_ctrl_add_handler(dev-cxhdl.hdl, core-video_hdl);
+   v4l2_ctrl_add_handler(dev-cxhdl.hdl, core-video_hdl, NULL);
 
/* blackbird stuff */
printk(%s/2: cx23416 based mpeg encoder (blackbird reference 
design)\n,
diff --git a/drivers/media/pci/cx88/cx88-video.c 
b/drivers/media/pci/cx88/cx88-video.c
index f6fcc7e..a146d50 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -1795,7 +1795,7 @@ static int __devinit cx8800_initdev(struct pci_dev 
*pci_dev,
if (vc-id == V4L2_CID_CHROMA_AGC)
core-chroma_agc = vc;
}
-   v4l2_ctrl_add_handler(core-video_hdl, core-audio_hdl);
+   v4l2_ctrl_add_handler(core-video_hdl, core-audio_hdl, NULL);
 
/* load and configure helper modules */
 
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 8e413dd..dde0901 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -472,7 +472,7 @@ int fimc_capture_ctrls_create(struct fimc_dev *fimc)
return ret;
 
return v4l2_ctrl_add_handler(vid_cap-ctx-ctrls.handler,
-   fimc-pipeline.subdevs[IDX_SENSOR]-ctrl_handler);
+   fimc-pipeline.subdevs[IDX_SENSOR]-ctrl_handler, NULL);
 }
 
 static int fimc_capture_set_default_format(struct fimc_dev *fimc);
diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index f6b1c1f..3be9294 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1184,7 +1184,7 @@ static int soc_camera_probe(struct soc_camera_device *icd)
sd-grp_id = soc_camera_grp_id(icd);
v4l2_set_subdev_hostdata(sd, icd);
 
-   if (v4l2_ctrl_add_handler(icd-ctrl_handler, sd-ctrl_handler))
+   if (v4l2_ctrl_add_handler(icd-ctrl_handler, sd-ctrl_handler, NULL))
goto ectrl;
 
/* At this point client .probe() should have run already */
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 43061e1..b1b4660 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1689,7 +1689,8 @@ EXPORT_SYMBOL(v4l2_ctrl_add_ctrl);
 
 /* Add the controls from another handler to our own. */
 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
- struct v4l2_ctrl_handler *add)
+ struct v4l2_ctrl_handler *add,
+ bool (*filter)(const struct v4l2_ctrl *ctrl))
 {
struct v4l2_ctrl_ref *ref;
int ret = 0;
@@ -1709,6 +1710,9 @@ int 

[PATCH 00/14] Media Controller capture driver for DM365

2012-09-14 Thread Prabhakar Lad
From: Lad, Prabhakar prabhakar@ti.com

This patch set adds media controller based capture driver for
DM365.

This driver bases its design on Laurent Pinchart's Media Controller Design
whose patches for Media Controller and subdev enhancements form the base.
The driver also takes copious elements taken from Laurent Pinchart and
others' OMAP ISP driver based on Media Controller. So thank you all the
people who are responsible for the Media Controller and the OMAP ISP driver.

Also, the core functionality of the driver comes from the arago vpfe capture
driver of which the CCDC capture was based on V4L2, with other drivers like
Previwer, and Resizer.

The current driver caters to dm6446,dm355 and dm365 of which the current
implementation works for dm365. The three VPFE IPs have some common elements
in terms of some high level functionality but there are differences in terms
of register definitions and some core blocks.

The individual specifications for each of these can be found here:
dm365  vpfe: http://www.ti.com/litv/pdf/sprufg8c
dm6446 vpfe: http://www.ti.com/litv/pdf/sprue38h
dm355  vpfe: http://www.ti.com/litv/pdf/spruf71a

This patch set has undergone reviewed several revisions.
(http://davinci-linux-open-source.1494791.n2.nabble.com/
RESEND-RFC-PATCH-v4-00-15-RFC-for-Media-Controller-capture-
driver-for-DM365-td7003648.html). This patches might be appearing
new due to the new folder structure changes to video drivers.

Manjunath Hadli (14):
  davinci: vpfe: add dm3xx IPIPEIF hardware support module
  davinci: vpfe: add IPIPE hardware layer support
  davinci: vpfe: add IPIPE support for media controller driver
  davinci: vpfe: add support for CCDC hardware for dm365
  davinci: vpfe: add ccdc driver with media controller interface
  davinci: vpfe: add v4l2 video driver support
  davinci: vpfe: v4l2 capture driver with media interface
  davinci: vpfe: previewer driver based on v4l2 media controller
framework
  davinci: vpfe: resizer driver based on media framework
  dm365: vpss: setup ISP registers
  dm365: vpss: set vpss clk ctrl
  dm365: vpss: add vpss helper functions to be used in the main driver
for setting hardware parameters
  davinci: vpfe: build infrastructure for dm365
  [media] davinci: vpfe: Add documentation

 Documentation/video4linux/davinci-vpfe-mc.txt|   95 +
 drivers/media/platform/davinci/Kconfig   |   40 +-
 drivers/media/platform/davinci/Makefile  |9 +
 drivers/media/platform/davinci/ccdc_hw_device.h  |   11 +-
 drivers/media/platform/davinci/dm355_ccdc.c  |2 +-
 drivers/media/platform/davinci/dm365_ccdc.c  | 1424 +
 drivers/media/platform/davinci/dm365_ccdc.h  |  137 +
 drivers/media/platform/davinci/dm365_ccdc_regs.h |  314 ++
 drivers/media/platform/davinci/dm365_def_para.c  |  294 ++
 drivers/media/platform/davinci/dm365_def_para.h  |   49 +
 drivers/media/platform/davinci/dm365_ipipe.c | 3673 ++
 drivers/media/platform/davinci/dm365_ipipe.h |  430 +++
 drivers/media/platform/davinci/dm365_ipipe_hw.c  |  936 ++
 drivers/media/platform/davinci/dm365_ipipe_hw.h  |  538 
 drivers/media/platform/davinci/dm3xx_ipipeif.c   |  318 ++
 drivers/media/platform/davinci/dm3xx_ipipeif.h   |  262 ++
 drivers/media/platform/davinci/dm644x_ccdc.c |2 +-
 drivers/media/platform/davinci/imp_hw_if.h   |  180 ++
 drivers/media/platform/davinci/isif.c|2 +-
 drivers/media/platform/davinci/vpfe_capture.c|2 +-
 drivers/media/platform/davinci/vpfe_ccdc.c   |  903 ++
 drivers/media/platform/davinci/vpfe_ccdc.h   |   87 +
 drivers/media/platform/davinci/vpfe_imp_common.h |   84 +
 drivers/media/platform/davinci/vpfe_mc_capture.c |  764 +
 drivers/media/platform/davinci/vpfe_mc_capture.h |  104 +
 drivers/media/platform/davinci/vpfe_previewer.c  | 1041 ++
 drivers/media/platform/davinci/vpfe_previewer.h  |   71 +
 drivers/media/platform/davinci/vpfe_resizer.c| 1080 +++
 drivers/media/platform/davinci/vpfe_resizer.h|   66 +
 drivers/media/platform/davinci/vpfe_video.c  | 1725 ++
 drivers/media/platform/davinci/vpfe_video.h  |  150 +
 drivers/media/platform/davinci/vpss.c|   56 +
 include/linux/davinci_vpfe.h |  929 ++
 include/linux/dm365_ccdc.h   |  592 
 include/linux/dm3xx_ipipeif.h|   62 +
 include/media/davinci/vpfe.h |   84 +
 include/media/davinci/vpss.h |   16 +
 37 files changed, 16518 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/video4linux/davinci-vpfe-mc.txt
 create mode 100644 drivers/media/platform/davinci/dm365_ccdc.c
 create mode 100644 drivers/media/platform/davinci/dm365_ccdc.h
 create mode 100644 drivers/media/platform/davinci/dm365_ccdc_regs.h
 create mode 100644 drivers/media/platform/davinci/dm365_def_para.c
 create mode 100644 

[PATCH 01/14] davinci: vpfe: add dm3xx IPIPEIF hardware support module

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

add support for dm3xx IPIPEIF hardware setup. This is the
lowest software layer for the dm3x vpfe driver which directly
accesses hardware. Add support for features like default
pixel correction, dark frame substraction and hardware setup.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/dm3xx_ipipeif.c |  318 
 drivers/media/platform/davinci/dm3xx_ipipeif.h |  262 +++
 include/linux/dm3xx_ipipeif.h  |   62 +
 3 files changed, 642 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/platform/davinci/dm3xx_ipipeif.c
 create mode 100644 drivers/media/platform/davinci/dm3xx_ipipeif.h
 create mode 100644 include/linux/dm3xx_ipipeif.h

diff --git a/drivers/media/platform/davinci/dm3xx_ipipeif.c 
b/drivers/media/platform/davinci/dm3xx_ipipeif.c
new file mode 100644
index 000..7961a74
--- /dev/null
+++ b/drivers/media/platform/davinci/dm3xx_ipipeif.c
@@ -0,0 +1,318 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ * Contributors:
+ *  Manjunath Hadli manjunath.ha...@ti.com
+ *  Prabhakar Lad prabhakar@ti.com
+ */
+
+#include linux/io.h
+#include linux/module.h
+#include linux/kernel.h
+#include linux/uaccess.h
+#include linux/v4l2-mediabus.h
+#include linux/platform_device.h
+
+#include dm3xx_ipipeif.h
+
+static void *__iomem ipipeif_base_addr;
+
+static inline u32 regr_if(u32 offset)
+{
+   return readl(ipipeif_base_addr + offset);
+}
+
+static inline void regw_if(u32 val, u32 offset)
+{
+   writel(val, ipipeif_base_addr + offset);
+}
+
+void ipipeif_set_enable()
+{
+   regw_if(1, IPIPEIF_ENABLE);
+}
+
+u32 ipipeif_get_enable(void)
+{
+   return regr_if(IPIPEIF_ENABLE);
+}
+
+int ipipeif_set_address(struct ipipeif *params, unsigned int address)
+{
+   u32 val;
+
+   if (params-source == 0)
+   return -EINVAL;
+
+   val = (params-adofs  5)  IPIPEIF_ADOFS_LSB_MASK;
+   regw_if(val, IPIPEIF_ADOFS);
+
+   /* lower sixteen bit */
+   val = (address  IPIPEIF_ADDRL_SHIFT)  IPIPEIF_ADDRL_MASK;
+   regw_if(val, IPIPEIF_ADDRL);
+
+   /* upper next seven bit */
+   val = (address  IPIPEIF_ADDRU_SHIFT)  IPIPEIF_ADDRU_MASK;
+   regw_if(val, IPIPEIF_ADDRU);
+
+   return 0;
+}
+
+static void ipipeif_config_dpc(struct ipipeif_dpc *dpc)
+{
+   u32 val = 0;
+
+   if (dpc-en) {
+   val = (dpc-en  1)  IPIPEIF_DPC2_EN_SHIFT;
+   val |= dpc-thr  IPIPEIF_DPC2_THR_MASK;
+   }
+
+   regw_if(val, IPIPEIF_DPC2);
+}
+
+#define RD_DATA_15_2   0x7
+
+/*
+ * ipipeif_hw_setup() - This function sets up IPIPEIF
+ */
+int ipipeif_hw_setup(struct ipipeif *params, int device_type)
+{
+   enum v4l2_mbus_pixelcode isif_port_if;
+   unsigned int val;
+
+   if (params == NULL)
+   return -EINVAL;
+
+   /* Enable clock to IPIPEIF and IPIPE */
+   if (device_type == DM365)
+   vpss_enable_clock(VPSS_IPIPEIF_CLOCK, 1);
+
+   /* Combine all the fields to make CFG1 register of IPIPEIF */
+   val = params-mode  ONESHOT_SHIFT;
+   val |= params-source  INPSRC_SHIFT;
+   val |= params-clock_select  CLKSEL_SHIFT;
+   val |= params-avg_filter  AVGFILT_SHIFT;
+   val |= params-decimation  DECIM_SHIFT;
+
+   if (device_type == DM355) {
+   val |= params-var.if_base.ialaw  IALAW_SHIFT;
+   val |= params-var.if_base.pack_mode  PACK8IN_SHIFT;
+   val |= params-var.if_base.clk_div  CLKDIV_SHIFT;
+   val |= params-var.if_base.data_shift  DATASFT_SHIFT;
+   } else {
+   /* DM365 IPIPE 5.1 */
+   val |= params-var.if_5_1.pack_mode  PACK8IN_SHIFT;
+   val |= params-var.if_5_1.source1  INPSRC1_SHIFT;
+   if (params-source != IPIPEIF_SDRAM_YUV)
+   val |= params-var.if_5_1.data_shift  DATASFT_SHIFT;
+   else
+   val = ~(RD_DATA_15_2  DATASFT_SHIFT);
+   }
+   regw_if(val, IPIPEIF_CFG1);
+
+   switch (params-source) {
+   case IPIPEIF_CCDC:
+   regw_if(params-gain, IPIPEIF_GAIN);
+   break;
+   case IPIPEIF_SDRAM_RAW:
+

[PATCH 02/14] davinci: vpfe: add IPIPE hardware layer support

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

add dm365 IPIPE hardware support. IPIPE is the hardware IP which
implements the functionality required for resizer, previewer and
the associated feature support. This is built along with the vpfe
driver, and implements hardware setup including coeffcient
programming for various hardware filters, gamma, cfa and clock
enable.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/dm365_ipipe_hw.c |  936 +++
 drivers/media/platform/davinci/dm365_ipipe_hw.h |  538 +
 2 files changed, 1474 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/platform/davinci/dm365_ipipe_hw.c
 create mode 100644 drivers/media/platform/davinci/dm365_ipipe_hw.h

diff --git a/drivers/media/platform/davinci/dm365_ipipe_hw.c 
b/drivers/media/platform/davinci/dm365_ipipe_hw.c
new file mode 100644
index 000..4ce6d95
--- /dev/null
+++ b/drivers/media/platform/davinci/dm365_ipipe_hw.c
@@ -0,0 +1,936 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ * Contributors:
+ *  Manjunath Hadli manjunath.ha...@ti.com
+ *  Prabhakar Lad prabhakar@ti.com
+ */
+
+#include linux/errno.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/v4l2-mediabus.h
+
+#include dm365_ipipe.h
+#include dm3xx_ipipeif.h
+#include dm365_ipipe_hw.h
+
+static void ipipe_clock_enable(void)
+{
+   /* enable IPIPE MMR for register write access */
+   regw_ip(IPIPE_GCK_MMR_DEFAULT, IPIPE_GCK_MMR);
+   /* enable the clock wb,cfa,dfc,d2f,pre modules */
+   regw_ip(IPIPE_GCK_PIX_DEFAULT, IPIPE_GCK_PIX);
+   /* enable RSZ MMR for register write access */
+}
+
+/* Set input channel format to either 420 Y or C format */
+void rsz_set_in_pix_format(unsigned char y_c)
+{
+   u32 val;
+
+   val = regr_rsz(RSZ_SRC_FMT1);
+   val |= y_c  1;
+   regw_rsz(val, RSZ_SRC_FMT1);
+}
+
+static void rsz_set_common_params(struct ipipe_params *params)
+{
+   struct rsz_common_params *rsz_common = params-rsz_common;
+   u32 val;
+
+   /* Set mode */
+   regw_rsz(params-ipipe_mode, RSZ_SRC_MODE);
+
+   /* data source selection  and bypass */
+   val = (rsz_common-passthrough  RSZ_BYPASS_SHIFT) |
+   rsz_common-source;
+
+   regw_rsz(val, RSZ_SRC_FMT0);
+   val = regr_rsz(RSZ_SRC_MODE);
+   /* src image selection */
+   val = (rsz_common-raw_flip  1) |
+   (rsz_common-src_img_fmt  RSZ_SRC_IMG_FMT_SHIFT) |
+   ((rsz_common-y_c  1)  RSZ_SRC_Y_C_SEL_SHIFT);
+
+   regw_rsz(val, RSZ_SRC_FMT1);
+   regw_rsz(rsz_common-vps  IPIPE_RSZ_VPS_MASK, RSZ_SRC_VPS);
+   regw_rsz(rsz_common-hps  IPIPE_RSZ_HPS_MASK, RSZ_SRC_HPS);
+   regw_rsz(rsz_common-vsz  IPIPE_RSZ_VSZ_MASK, RSZ_SRC_VSZ);
+   regw_rsz(rsz_common-hsz  IPIPE_RSZ_HSZ_MASK, RSZ_SRC_HSZ);
+   regw_rsz(rsz_common-yuv_y_min, RSZ_YUV_Y_MIN);
+   regw_rsz(rsz_common-yuv_y_max, RSZ_YUV_Y_MAX);
+   regw_rsz(rsz_common-yuv_c_min, RSZ_YUV_C_MIN);
+   regw_rsz(rsz_common-yuv_c_max, RSZ_YUV_C_MAX);
+   /* chromatic position */
+   regw_rsz(rsz_common-out_chr_pos, RSZ_YUV_PHS);
+   val = regr_rsz(RSZ_SRC_MODE);
+}
+
+static void rsz_set_rsz_regs(unsigned int rsz_id, struct ipipe_params *params)
+{
+   struct ipipe_rsz_rescale_param *rsc_params;
+   struct ipipe_ext_mem_param *ext_mem;
+   struct ipipe_rsz_resize2rgb *rgb;
+   u32 reg_base;
+   u32 val;
+
+   val = regr_rsz(RSZ_SEQ);
+   rsc_params = params-rsz_rsc_param[rsz_id];
+   rgb = params-rsz2rgb[rsz_id];
+   ext_mem = params-ext_mem_param[rsz_id];
+
+   if (rsz_id == RSZ_A) {
+   val = rsc_params-h_flip  RSZA_H_FLIP_SHIFT;
+   val |= rsc_params-v_flip  RSZA_V_FLIP_SHIFT;
+   reg_base = RSZ_EN_A;
+   } else {
+   val = rsc_params-h_flip  RSZB_H_FLIP_SHIFT;
+   val |= rsc_params-v_flip  RSZB_V_FLIP_SHIFT;
+   reg_base = RSZ_EN_B;
+   }
+   /* update flip settings */
+   regw_rsz(val, RSZ_SEQ);
+
+   regw_rsz(rsc_params-mode, reg_base + RSZ_MODE);
+   val = (rsc_params-cen  RSZ_CEN_SHIFT) | rsc_params-yen;
+   regw_rsz(val, reg_base + RSZ_420);
+   

[PATCH 08/14] davinci: vpfe: previewer driver based on v4l2 media controller framework

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

Add the video previewer driver with the v4l2 media controller framework
which takes care of converting the video frames from bayer to YUV or RGB.
The driver supports both continuous mode where it works in tandem with
the CCDC and single shot mode where it can be used in isolation. The
driver underneath uses the dm365 IPIPE module for programming the
hardware. The driver supports previewer as a subdevice and a media entity,
and the enumerable pads are 2(1 input and 1 output). The driver supports
streaing and all the pad and link related operations. Specific functions
like defect pixel correction, LUT are supported through private ioctls.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpfe_previewer.c | 1041 +++
 drivers/media/platform/davinci/vpfe_previewer.h |   71 ++
 2 files changed, 1112 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/platform/davinci/vpfe_previewer.c
 create mode 100644 drivers/media/platform/davinci/vpfe_previewer.h

diff --git a/drivers/media/platform/davinci/vpfe_previewer.c 
b/drivers/media/platform/davinci/vpfe_previewer.c
new file mode 100644
index 000..4a0fc8e
--- /dev/null
+++ b/drivers/media/platform/davinci/vpfe_previewer.c
@@ -0,0 +1,1041 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ * Contributors:
+ *  Manjunath Hadli manjunath.ha...@ti.com
+ *  Prabhakar Lad prabhakar@ti.com
+ */
+
+#include linux/slab.h
+#include linux/videodev2.h
+#include linux/v4l2-mediabus.h
+#include linux/platform_device.h
+#include linux/davinci_vpfe.h
+
+#include media/v4l2-device.h
+#include media/davinci/vpss.h
+#include media/media-entity.h
+#include media/davinci/vpfe_types.h
+
+#include vpfe_mc_capture.h
+#include imp_hw_if.h
+
+#define MIN_OUT_WIDTH  32
+#define MIN_OUT_HEIGHT 32
+
+static int serializer_initialized;
+static struct imp_serializer imp_serializer_info;
+
+/* previewer input format descriptions */
+static const unsigned int prev_input_fmts[] = {
+   V4L2_MBUS_FMT_UYVY8_2X8,
+   V4L2_MBUS_FMT_SGRBG12_1X12,
+};
+
+/* previewer ouput format descriptions */
+static const unsigned int prev_output_fmts[] = {
+   V4L2_MBUS_FMT_UYVY8_2X8,
+};
+
+/*
+ * imp_set_preview_config() - set previewer config
+ * @sd: Pointer previewer subdevice
+ * @chan_config: previewer channel configuration
+ */
+static int
+imp_set_preview_config(struct v4l2_subdev *sd,
+  struct vpfe_prev_config *chan_config)
+{
+   struct vpfe_previewer_device *previewer = v4l2_get_subdevdata(sd);
+   struct imp_logical_channel *channel = previewer-channel;
+   struct imp_hw_interface *imp_hw_if = previewer-imp_hw_if;
+   struct vpfe_device *vpfe_dev = to_vpfe_device(previewer);
+   struct device *dev = previewer-subdev.v4l2_dev-dev;
+   int ret;
+
+   if (channel-config_state == STATE_NOT_CONFIGURED) {
+   channel-config = imp_hw_if-alloc_config_block(dev,
+   vpfe_dev-ipipe);
+   /* allocate buffer for holding user configuration */
+   channel-user_config = imp_hw_if-alloc_user_config_block(dev,
+   vpfe_dev-ipipe, IMP_PREVIEWER);
+   if (!channel-user_config) {
+   dev_err(dev,
+   Failed to allocate memory for user config\n);
+   return -EFAULT;
+   }
+   }
+
+   if (!chan_config-ipipeif_config) {
+   dev_dbg(dev, imp_set_preview_config: default configuration 
set\n);
+   /* put defaults for user configuration */
+   imp_hw_if-set_user_config_defaults(dev, vpfe_dev-ipipe,
+   IMP_PREVIEWER, channel-user_config);
+   } else {
+   dev_dbg(dev, imp_set_preview_config: user configuration 
set\n);
+   if (copy_from_user(channel-user_config,
+   chan_config-ipipeif_config,
+   sizeof(struct prev_ipipeif_config)))
+   return -EFAULT;
+   }
+
+   /* Update the user configuration in the hw config block */
+   

[PATCH 10/14] dm365: vpss: setup ISP registers

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

enable PPCR, enbale ISIF out on BCR and disable all events.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpss.c |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/media/platform/davinci/vpss.c 
b/drivers/media/platform/davinci/vpss.c
index 146e4b0..34ad7bd 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -52,9 +52,11 @@ MODULE_AUTHOR(Texas Instruments);
 #define DM355_VPSSBL_EVTSEL_DEFAULT0x4
 
 #define DM365_ISP5_PCCR0x04
+#define DM365_ISP5_BCR 0x08
 #define DM365_ISP5_INTSEL1 0x10
 #define DM365_ISP5_INTSEL2 0x14
 #define DM365_ISP5_INTSEL3 0x18
+#define DM365_ISP5_EVTSEL  0x1c
 #define DM365_ISP5_CCDCMUX 0x20
 #define DM365_ISP5_PG_FRAME_SIZE   0x28
 #define DM365_VPBE_CLK_CTRL0x00
@@ -357,6 +359,10 @@ void dm365_vpss_set_pg_frame_size(struct 
vpss_pg_frame_size frame_size)
 }
 EXPORT_SYMBOL(dm365_vpss_set_pg_frame_size);
 
+#define DM365_ISP5_EVTSEL_EVT_DISABLE  0x
+#define DM365_ISP5_BCR_ISIF_OUT_ENABLE 0x0002
+#define DM365_ISP5_PCCR_CLK_ENABLE 0x007f
+
 static int __devinit vpss_probe(struct platform_device *pdev)
 {
struct resource *r1, *r2;
@@ -426,9 +432,16 @@ static int __devinit vpss_probe(struct platform_device 
*pdev)
oper_cfg.hw_ops.enable_clock = dm365_enable_clock;
oper_cfg.hw_ops.select_ccdc_source = dm365_select_ccdc_source;
/* Setup vpss interrupts */
+   isp5_write((isp5_read(DM365_ISP5_PCCR) |
+   DM365_ISP5_PCCR_CLK_ENABLE), DM365_ISP5_PCCR);
+   isp5_write((isp5_read(DM365_ISP5_BCR) |
+DM365_ISP5_BCR_ISIF_OUT_ENABLE), DM365_ISP5_BCR);
isp5_write(DM365_ISP5_INTSEL1_DEFAULT, DM365_ISP5_INTSEL1);
isp5_write(DM365_ISP5_INTSEL2_DEFAULT, DM365_ISP5_INTSEL2);
isp5_write(DM365_ISP5_INTSEL3_DEFAULT, DM365_ISP5_INTSEL3);
+   /* No event selected */
+   isp5_write((isp5_read(DM365_ISP5_EVTSEL) |
+   DM365_ISP5_EVTSEL_EVT_DISABLE), DM365_ISP5_EVTSEL);
} else
oper_cfg.hw_ops.clear_wbl_overflow = dm644x_clear_wbl_overflow;
 
-- 
1.7.4.1

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


[PATCH 12/14] dm365: vpss: add vpss helper functions to be used in the main driver for setting hardware parameters

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

add function to set sync polarity , interrupt completion and
pageframe size in vpss to be used by the main driver.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpss.c |   32 
 include/media/davinci/vpss.h  |   16 
 2 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/drivers/media/platform/davinci/vpss.c 
b/drivers/media/platform/davinci/vpss.c
index 49bb045..3c195c0 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -97,6 +97,12 @@ struct vpss_hw_ops {
void (*select_ccdc_source)(enum vpss_ccdc_source_sel src_sel);
/* clear wbl overflow bit */
int (*clear_wbl_overflow)(enum vpss_wbl_sel wbl_sel);
+   /* set sync polarity */
+   void (*set_sync_pol)(struct vpss_sync_pol);
+   /* set the PG_FRAME_SIZE register*/
+   void (*set_pg_frame_size)(struct vpss_pg_frame_size);
+   /* check and clear interrupt if occured */
+   int (*dma_complete_interrupt)(void);
 };
 
 /* vpss configuration */
@@ -161,6 +167,14 @@ static void dm355_select_ccdc_source(enum 
vpss_ccdc_source_sel src_sel)
bl_regw(src_sel  VPSS_HSSISEL_SHIFT, DM355_VPSSBL_CCDCMUX);
 }
 
+int vpss_dma_complete_interrupt(void)
+{
+   if (!oper_cfg.hw_ops.dma_complete_interrupt)
+   return 2;
+   return oper_cfg.hw_ops.dma_complete_interrupt();
+}
+EXPORT_SYMBOL(vpss_dma_complete_interrupt);
+
 int vpss_select_ccdc_source(enum vpss_ccdc_source_sel src_sel)
 {
if (!oper_cfg.hw_ops.select_ccdc_source)
@@ -186,6 +200,15 @@ static int dm644x_clear_wbl_overflow(enum vpss_wbl_sel 
wbl_sel)
return 0;
 }
 
+void vpss_set_sync_pol(struct vpss_sync_pol sync)
+{
+   if (!oper_cfg.hw_ops.set_sync_pol)
+   return;
+
+   oper_cfg.hw_ops.set_sync_pol(sync);
+}
+EXPORT_SYMBOL(vpss_set_sync_pol);
+
 int vpss_clear_wbl_overflow(enum vpss_wbl_sel wbl_sel)
 {
if (!oper_cfg.hw_ops.clear_wbl_overflow)
@@ -351,6 +374,15 @@ void dm365_vpss_set_sync_pol(struct vpss_sync_pol sync)
 }
 EXPORT_SYMBOL(dm365_vpss_set_sync_pol);
 
+void vpss_set_pg_frame_size(struct vpss_pg_frame_size frame_size)
+{
+   if (!oper_cfg.hw_ops.set_pg_frame_size)
+   return;
+
+   oper_cfg.hw_ops.set_pg_frame_size(frame_size);
+}
+EXPORT_SYMBOL(vpss_set_pg_frame_size);
+
 void dm365_vpss_set_pg_frame_size(struct vpss_pg_frame_size frame_size)
 {
int current_reg = ((frame_size.hlpfr  1) - 1)  16;
diff --git a/include/media/davinci/vpss.h b/include/media/davinci/vpss.h
index b586495..c5f6d9a 100644
--- a/include/media/davinci/vpss.h
+++ b/include/media/davinci/vpss.h
@@ -105,4 +105,20 @@ enum vpss_wbl_sel {
 };
 /* clear wbl overflow flag for DM6446 */
 int vpss_clear_wbl_overflow(enum vpss_wbl_sel wbl_sel);
+
+/* set sync polarity*/
+void vpss_set_sync_pol(struct vpss_sync_pol sync);
+/* set the PG_FRAME_SIZE register */
+void vpss_set_pg_frame_size(struct vpss_pg_frame_size frame_size);
+/**
+ * vpss_check_and_clear_interrupt - check and clear interrupt
+ * @irq - common enumerator for IRQ
+ *
+ * Following return values used:-
+ * 0 - interrupt occured and cleared
+ * 1 - interrupt not occured
+ * 2 - interrupt status not available
+ */
+int vpss_dma_complete_interrupt(void);
+
 #endif
-- 
1.7.4.1

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


[PATCH 13/14] davinci: vpfe: build infrastructure for dm365

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

add build infrastructure for dm365 specific modules
such as IPIPE, AEW, AF.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/Kconfig  |   40 +-
 drivers/media/platform/davinci/Makefile |9 +++
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/Kconfig 
b/drivers/media/platform/davinci/Kconfig
index 78e26d2..4eddb00 100644
--- a/drivers/media/platform/davinci/Kconfig
+++ b/drivers/media/platform/davinci/Kconfig
@@ -56,7 +56,7 @@ config VIDEO_VPFE_CAPTURE
 
 config VIDEO_DM6446_CCDC
tristate DM6446 CCDC HW module
-   depends on VIDEO_VPFE_CAPTURE
+   depends on VIDEO_VPFE_CAPTURE  ARCH_DAVINCI_DM644x
select VIDEO_VPSS_SYSTEM
default y
help
@@ -85,7 +85,7 @@ config VIDEO_DM355_CCDC
   module will be called vpfe.
 
 config VIDEO_ISIF
-   tristate ISIF HW module
+   tristate DM365 ISIF HW module
depends on ARCH_DAVINCI_DM365  VIDEO_VPFE_CAPTURE
select VIDEO_VPSS_SYSTEM
default y
@@ -119,3 +119,39 @@ config VIDEO_VPBE_DISPLAY
 
To compile this driver as a module, choose M here: the
module will be called vpbe_display.
+
+
+config VIDEO_365_CCDC
+   tristate DM365 CCDC HW module
+   depends on ARCH_DAVINCI_DM365  VIDEO_VPFE_MC_CAPTURE
+   select VIDEO_VPSS_SYSTEM
+   default y
+   help
+  Enables ISIF hw module. This is the hardware module for
+  configuring ISIF in VPFE to capture Raw Bayer RGB data  from
+  a image sensor or YUV data from a YUV source.
+
+  To compile this driver as a module, choose M here: the
+  module will be called vpfe.
+
+config DM365_IPIPE
+   depends on ARCH_DAVINCI  ARCH_DAVINCI_DM365  VIDEO_VPFE_MC_CAPTURE
+   tristate DM365 IPIPE
+   help
+ dm365 IPIPE hardware module.
+
+ This is the hardware module that implements imp_hw_interface
+ for DM365. This hardware module provides previewer and resizer
+ functionality for image processing.
+
+config VIDEO_VPFE_MC_CAPTURE
+   tristate VPFE Media Controller Capture Driver
+   depends on VIDEO_V4L2  (ARCH_DAVINCI)  !VIDEO_VPFE_CAPTURE
+   select VIDEOBUF_DMA_CONTIG
+   help
+ Support for DMx/AMx VPFE based Media Controller Capture driver. This 
is the
+ common V4L2 module for following DMx/AMx SoCs from Texas
+ Instruments:- DM6446, DM365, DM355  AM3517/05.
+
+ To compile this driver as a module, choose M here: the
+ module will be called vpfe-mc-capture.
diff --git a/drivers/media/platform/davinci/Makefile 
b/drivers/media/platform/davinci/Makefile
index 74ed92d..955f63d 100644
--- a/drivers/media/platform/davinci/Makefile
+++ b/drivers/media/platform/davinci/Makefile
@@ -16,5 +16,14 @@ obj-$(CONFIG_VIDEO_VPFE_CAPTURE) += vpfe_capture.o
 obj-$(CONFIG_VIDEO_DM6446_CCDC) += dm644x_ccdc.o
 obj-$(CONFIG_VIDEO_DM355_CCDC) += dm355_ccdc.o
 obj-$(CONFIG_VIDEO_ISIF) += isif.o
+obj-$(CONFIG_VIDEO_365_CCDC) += dm365_ccdc.o
+obj-$(CONFIG_VIDEO_VPFE_MC_CAPTURE) += vpfe_mc_capture.o \
+   vpfe_ccdc.o vpfe_resizer.o vpfe_previewer.o \
+   vpfe_video.o
+
+dm365_imp-objs := dm365_ipipe.o dm365_def_para.o \
+   dm365_ipipe_hw.o dm3xx_ipipeif.o
+obj-$(CONFIG_DM365_IPIPE) += dm365_imp.o
+
 obj-$(CONFIG_VIDEO_DM644X_VPBE) += vpbe.o vpbe_osd.o vpbe_venc.o
 obj-$(CONFIG_VIDEO_VPBE_DISPLAY) += vpbe_display.o
-- 
1.7.4.1

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


[PATCH 11/14] dm365: vpss: set vpss clk ctrl

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

request_mem_region for VPSS_CLK_CTRL register and ioremap.
and enable clocks appropriately.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpss.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/media/platform/davinci/vpss.c 
b/drivers/media/platform/davinci/vpss.c
index 34ad7bd..49bb045 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -103,6 +103,7 @@ struct vpss_hw_ops {
 struct vpss_oper_config {
__iomem void *vpss_regs_base0;
__iomem void *vpss_regs_base1;
+   resource_size_t *vpss_regs_base2;
enum vpss_platform_type platform;
spinlock_t vpss_lock;
struct vpss_hw_ops hw_ops;
@@ -484,11 +485,21 @@ static struct platform_driver vpss_driver = {
 
 static void vpss_exit(void)
 {
+   iounmap(oper_cfg.vpss_regs_base2);
+   release_mem_region(*oper_cfg.vpss_regs_base2, 4);
platform_driver_unregister(vpss_driver);
 }
 
+#define VPSS_CLK_CTRL  0x01c40044
+
 static int __init vpss_init(void)
 {
+   if (request_mem_region(VPSS_CLK_CTRL, 4, vpss_clock_control)) {
+   oper_cfg.vpss_regs_base2 = ioremap(VPSS_CLK_CTRL, 4);
+   __raw_writel(0x18, oper_cfg.vpss_regs_base2);
+   } else {
+   return -EBUSY;
+   }
return platform_driver_register(vpss_driver);
 }
 subsys_initcall(vpss_init);
-- 
1.7.4.1

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


[PATCH 09/14] davinci: vpfe: resizer driver based on media framework

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

Add the video resizer driver with the v4l2 media controller framework
which takes care of resizing the video frames with both up-scaling
downscaling facility. The formats that is supported is YUV422.
The driver supports both continuous mode where it works in
tandem with the CCDC and previewer and single shot mode where
it can be used in isolation or with previewer. The driver underneath
uses the dm365 IPIPE module for programming the hardware.
The driver supports resizer as a subdevice and a media entity,
and the enumerable pads are 2(1 input and 1 output). The driver
supports streaming and all the pad and link related operations.
Specific filter functionality including filter types are set
through private ioctls.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpfe_resizer.c | 1080 +
 drivers/media/platform/davinci/vpfe_resizer.h |   66 ++
 2 files changed, 1146 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/platform/davinci/vpfe_resizer.c
 create mode 100644 drivers/media/platform/davinci/vpfe_resizer.h

diff --git a/drivers/media/platform/davinci/vpfe_resizer.c 
b/drivers/media/platform/davinci/vpfe_resizer.c
new file mode 100644
index 000..8b98ff5
--- /dev/null
+++ b/drivers/media/platform/davinci/vpfe_resizer.c
@@ -0,0 +1,1080 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ * Contributors:
+ *  Manjunath Hadli manjunath.ha...@ti.com
+ *  Prabhakar Lad prabhakar@ti.com
+ */
+
+#include linux/slab.h
+#include linux/videodev2.h
+#include linux/platform_device.h
+#include linux/v4l2-mediabus.h
+
+#include media/v4l2-device.h
+#include media/media-entity.h
+#include media/davinci/vpss.h
+#include media/davinci/vpfe_types.h
+
+#include vpfe_mc_capture.h
+#include imp_hw_if.h
+
+
+#define MIN_IN_WIDTH   32
+#define MIN_IN_HEIGHT  32
+#define MAX_IN_WIDTH   4095
+#define MAX_IN_HEIGHT  4095
+#define MIN_OUT_WIDTH  16
+#define MIN_OUT_HEIGHT 2
+
+/* resizer pixel formats */
+static const unsigned int resz_input_fmts[] = {
+   V4L2_MBUS_FMT_UYVY8_2X8,
+#ifdef CONFIG_ARCH_DAVINCI_DM365
+   V4L2_MBUS_FMT_Y8_1X8,
+   V4L2_MBUS_FMT_UV8_1X8,
+#endif
+};
+
+static const unsigned int resz_output_fmts[] = {
+   V4L2_MBUS_FMT_UYVY8_2X8,
+#ifdef CONFIG_ARCH_DAVINCI_DM365
+   V4L2_MBUS_FMT_Y8_1X8,
+   V4L2_MBUS_FMT_UV8_1X8,
+   V4L2_MBUS_FMT_YDYUYDYV8_1X16,
+#endif
+};
+
+static char resizer_chained;
+/*
+ * imp_set_resizer_config() - set resizer config
+ * @resizer: vpfe resizer device pointer
+ * @channel: image processor logical channel
+ * @chan_config: resizer channel configuration
+ */
+static int imp_set_resizer_config(struct vpfe_resizer_device *resizer,
+  struct imp_logical_channel *channel,
+  struct vpfe_rsz_config *chan_config)
+{
+   struct imp_hw_interface *imp_hw_if = resizer-imp_hw_if;
+   struct device *dev = resizer-subdev.v4l2_dev-dev;
+   struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
+   int ret;
+
+   if (channel-config_state == STATE_NOT_CONFIGURED) {
+   channel-config =
+   imp_hw_if-alloc_config_block(dev, vpfe_dev-ipipe);
+
+   if (!channel-config) {
+   dev_err(dev,
+   Failed to allocate memory for channel config\n);
+   return -EFAULT;
+   }
+   /* allocate buffer for holding user configuration */
+   channel-user_config = imp_hw_if-alloc_user_config_block(dev,
+   vpfe_dev-ipipe, IMP_RESIZER);
+
+   if (!channel-user_config) {
+   dev_err(dev,
+   Failed to allocate memory for user config\n);
+   if (!resizer_chained)
+   kfree(channel-config);
+   return -EFAULT;
+   }
+   }
+
+   if (!chan_config-config) {
+   /* put defaults for user configuration */
+   imp_hw_if-set_user_config_defaults(dev, vpfe_dev-ipipe,
+   

[PATCH 05/14] davinci: vpfe: add ccdc driver with media controller interface

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

Add the CCDC driver for davinci Dm3XX SoCs. The driver supports
CCDC as a media entity with 2 pads - 1 input and 1 output. The
driver implements streaming support and subdev interface. The
ccdc supports bayer and YUV formats.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/ccdc_hw_device.h |   11 +-
 drivers/media/platform/davinci/dm355_ccdc.c |2 +-
 drivers/media/platform/davinci/dm644x_ccdc.c|2 +-
 drivers/media/platform/davinci/isif.c   |2 +-
 drivers/media/platform/davinci/vpfe_capture.c   |2 +-
 drivers/media/platform/davinci/vpfe_ccdc.c  |  903 +++
 drivers/media/platform/davinci/vpfe_ccdc.h  |   87 +++
 7 files changed, 997 insertions(+), 12 deletions(-)
 create mode 100644 drivers/media/platform/davinci/vpfe_ccdc.c
 create mode 100644 drivers/media/platform/davinci/vpfe_ccdc.h

diff --git a/drivers/media/platform/davinci/ccdc_hw_device.h 
b/drivers/media/platform/davinci/ccdc_hw_device.h
index 86b9b35..43615d7 100644
--- a/drivers/media/platform/davinci/ccdc_hw_device.h
+++ b/drivers/media/platform/davinci/ccdc_hw_device.h
@@ -57,7 +57,7 @@ struct ccdc_hw_ops {
 */
int (*get_params) (void *params);
/* Pointer to function to configure ccdc */
-   int (*configure) (void);
+   int (*configure) (int mode);
 
/* Pointer to function to set buffer type */
int (*set_buftype) (enum ccdc_buftype buf_type);
@@ -80,17 +80,12 @@ struct ccdc_hw_ops {
/* Pointer to function to get line length */
unsigned int (*get_line_length) (void);
 
-   /* Query CCDC control IDs */
-   int (*queryctrl)(struct v4l2_queryctrl *qctrl);
-   /* Set CCDC control */
-   int (*set_control)(struct v4l2_control *ctrl);
-   /* Get CCDC control */
-   int (*get_control)(struct v4l2_control *ctrl);
-
/* Pointer to function to set frame buffer address */
void (*setfbaddr) (unsigned long addr);
/* Pointer to function to get field id */
int (*getfid) (void);
+   /* Pointer to function to set_ctrl */
+   int (*set_ctrl) (u32 ctrl_id, s32 val);
 };
 
 struct ccdc_hw_device {
diff --git a/drivers/media/platform/davinci/dm355_ccdc.c 
b/drivers/media/platform/davinci/dm355_ccdc.c
index ce0e413..c5563fd 100644
--- a/drivers/media/platform/davinci/dm355_ccdc.c
+++ b/drivers/media/platform/davinci/dm355_ccdc.c
@@ -779,7 +779,7 @@ static int ccdc_config_raw(void)
return 0;
 }
 
-static int ccdc_configure(void)
+static int ccdc_configure(int mode)
 {
if (ccdc_cfg.if_type == VPFE_RAW_BAYER)
return ccdc_config_raw();
diff --git a/drivers/media/platform/davinci/dm644x_ccdc.c 
b/drivers/media/platform/davinci/dm644x_ccdc.c
index ee7942b..e51776a 100644
--- a/drivers/media/platform/davinci/dm644x_ccdc.c
+++ b/drivers/media/platform/davinci/dm644x_ccdc.c
@@ -689,7 +689,7 @@ void ccdc_config_raw(void)
ccdc_readregs();
 }
 
-static int ccdc_configure(void)
+static int ccdc_configure(int mode)
 {
if (ccdc_cfg.if_type == VPFE_RAW_BAYER)
ccdc_config_raw();
diff --git a/drivers/media/platform/davinci/isif.c 
b/drivers/media/platform/davinci/isif.c
index b99d542..3e4fe87 100644
--- a/drivers/media/platform/davinci/isif.c
+++ b/drivers/media/platform/davinci/isif.c
@@ -993,7 +993,7 @@ static int isif_config_ycbcr(void)
return 0;
 }
 
-static int isif_configure(void)
+static int isif_configure(int mode)
 {
if (isif_cfg.if_type == VPFE_RAW_BAYER)
return isif_config_raw();
diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index 843b138..59cafa8 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1572,7 +1572,7 @@ static int vpfe_streamon(struct file *file, void *priv,
ret = -EFAULT;
goto unlock_out;
}
-   if (ccdc_dev-hw_ops.configure()  0) {
+   if (ccdc_dev-hw_ops.configure(0)  0) {
v4l2_err(vpfe_dev-v4l2_dev,
 Error in configuring ccdc\n);
ret = -EINVAL;
diff --git a/drivers/media/platform/davinci/vpfe_ccdc.c 
b/drivers/media/platform/davinci/vpfe_ccdc.c
new file mode 100644
index 000..fdc0aa4
--- /dev/null
+++ b/drivers/media/platform/davinci/vpfe_ccdc.c
@@ -0,0 +1,903 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU 

[PATCH 06/14] davinci: vpfe: add v4l2 video driver support

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

add a generic video driver functionality to be used by all the vpfe
drivers for davinci SoCs. The functionality includes all the
standard v4l2 interfaces including streaming. The video node
interface can be used both as an input and output node for both
continuous and single shot modes.Also supports dv_presets to include
HD modes, wth support for both user pointer IO and mmap.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpfe_video.c | 1725 +++
 drivers/media/platform/davinci/vpfe_video.h |  150 +++
 2 files changed, 1875 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/platform/davinci/vpfe_video.c
 create mode 100644 drivers/media/platform/davinci/vpfe_video.h

diff --git a/drivers/media/platform/davinci/vpfe_video.c 
b/drivers/media/platform/davinci/vpfe_video.c
new file mode 100644
index 000..2e696a0
--- /dev/null
+++ b/drivers/media/platform/davinci/vpfe_video.c
@@ -0,0 +1,1725 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ * Contributors:
+ *  Manjunath Hadli manjunath.ha...@ti.com
+ *  Prabhakar Lad prabhakar@ti.com
+ */
+
+#include linux/slab.h
+#include linux/module.h
+#include linux/platform_device.h
+
+#include media/v4l2-common.h
+#include media/v4l2-mediabus.h
+#include media/media-entity.h
+#include media/media-device.h
+#include media/davinci/vpfe_types.h
+
+#include mach/cputype.h
+
+#include vpfe_mc_capture.h
+#include ccdc_hw_device.h
+
+/* minimum number of buffers needed in cont-mode */
+#define CONT_MIN_NUM_BUFFERS   3
+
+static int debug;
+
+/* get v4l2 subdev pointer to external subdev which is active */
+static struct media_entity *vpfe_get_input_entity
+   (struct vpfe_video_device *video)
+{
+   struct vpfe_device *vpfe_dev = video-vpfe_dev;
+   struct media_pad *remote;
+
+   remote = media_entity_remote_source(vpfe_dev-vpfe_ccdc.pads[0]);
+   if (remote == NULL) {
+   pr_err(Invalid media connection to ccdc\n);
+   return NULL;
+   }
+
+   return remote-entity;
+}
+
+/* updates external subdev(sensor/decoder) which is active */
+static int vpfe_update_current_ext_subdev(struct vpfe_video_device *video)
+{
+   struct vpfe_device *vpfe_dev = video-vpfe_dev;
+   struct vpfe_config *vpfe_cfg;
+   struct v4l2_subdev *subdev;
+   struct media_pad *remote;
+   int i;
+
+   remote = media_entity_remote_source(vpfe_dev-vpfe_ccdc.pads[0]);
+   if (remote == NULL) {
+   pr_err(Invalid media connection to ccdc\n);
+   return -EINVAL;
+   }
+
+   subdev = media_entity_to_v4l2_subdev(remote-entity);
+
+   vpfe_cfg = vpfe_dev-pdev-platform_data;
+
+   for (i = 0; i  vpfe_cfg-num_subdevs; i++) {
+   if (!strcmp(vpfe_cfg-sub_devs[i].module_name, subdev-name)) {
+   video-current_ext_subdev = vpfe_cfg-sub_devs[i];
+   break;
+   }
+   }
+
+   /* if user not linked decoder/sensor to ccdc */
+   if (i == vpfe_cfg-num_subdevs) {
+   pr_err(Invalid media chain connection to ccdc\n);
+   return -EINVAL;
+   }
+
+   /* find the v4l2 subdev pointer */
+   for (i = 0; i  vpfe_dev-num_ext_subdevs; i++) {
+   if (!strcmp(video-current_ext_subdev-module_name,
+   vpfe_dev-sd[i]-name))
+   video-current_ext_subdev-subdev = vpfe_dev-sd[i];
+   }
+
+   return 0;
+}
+
+/* get the subdev which is connected to the output video node */
+static struct v4l2_subdev *
+vpfe_video_remote_subdev(struct vpfe_video_device *video, u32 *pad)
+{
+   struct media_pad *remote;
+
+   remote = media_entity_remote_source(video-pad);
+
+   if (remote == NULL || remote-entity-type != MEDIA_ENT_T_V4L2_SUBDEV)
+   return NULL;
+
+   if (pad)
+   *pad = remote-index;
+
+   return media_entity_to_v4l2_subdev(remote-entity);
+}
+
+/* get the format set at ouput pad of the adjacent subdev */
+static int
+__vpfe_video_get_format(struct vpfe_video_device *video,
+   struct v4l2_format *format)
+{
+   struct 

[PATCH 07/14] davinci: vpfe: v4l2 capture driver with media interface

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

Add the vpfe capture driver which implements media controller
interface. The driver suports all the setup functionality for
all all units nnamely- ccdc, previewer, resizer, h3a, aew.
The driver supports both dm365 and Dm355. The driver does isr
registration, v4l2 device registration, media registration and
platform driver registrations. It calls the appropriate subdevs
from here to cerate the appropriate subdevices and media entities.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpfe_mc_capture.c |  764 ++
 drivers/media/platform/davinci/vpfe_mc_capture.h |  104 +++
 include/media/davinci/vpfe.h |   84 +++
 3 files changed, 952 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/platform/davinci/vpfe_mc_capture.c
 create mode 100644 drivers/media/platform/davinci/vpfe_mc_capture.h
 create mode 100644 include/media/davinci/vpfe.h

diff --git a/drivers/media/platform/davinci/vpfe_mc_capture.c 
b/drivers/media/platform/davinci/vpfe_mc_capture.c
new file mode 100644
index 000..306d45f
--- /dev/null
+++ b/drivers/media/platform/davinci/vpfe_mc_capture.c
@@ -0,0 +1,764 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ * Contributors:
+ *  Manjunath Hadli manjunath.ha...@ti.com
+ *  Prabhakar Lad prabhakar@ti.com
+ *
+ *
+ * Driver name : VPFE Capture driver
+ *VPFE Capture driver allows applications to capture and stream video
+ *frames on DaVinci SoCs (DM6446, DM355 etc) from a YUV source such as
+ *TVP5146 or  Raw Bayer RGB image data from an image sensor
+ *such as Microns' MT9T001, MT9T031 etc.
+ *
+ *These SoCs have, in common, a Video Processing Subsystem (VPSS) that
+ *consists of a Video Processing Front End (VPFE) for capturing
+ *video/raw image data and Video Processing Back End (VPBE) for displaying
+ *YUV data through an in-built analog encoder or Digital LCD port. This
+ *driver is for capture through VPFE. A typical EVM using these SoCs have
+ *following high level configuration.
+ *
+ *decoder(TVP5146/ YUV/
+ * MT9T001)   --  Raw Bayer RGB --- MUX - VPFE (CCDC/ISIF)
+ * data input  |  |
+ * V  |
+ *   SDRAM|
+ *V
+ *Image Processor
+ *|
+ *V
+ *  SDRAM
+ *The data flow happens from a decoder connected to the VPFE over a
+ *YUV embedded (BT.656/BT.1120) or separate sync or raw bayer rgb interface
+ *and to the input of VPFE through an optional MUX (if more inputs are
+ *to be interfaced on the EVM). The input data is first passed through
+ *CCDC (CCD Controller, a.k.a Image Sensor Interface, ISIF). The CCDC
+ *does very little or no processing on YUV data and does pre-process Raw
+ *Bayer RGB data through modules such as Defect Pixel Correction (DFC)
+ *Color Space Conversion (CSC), data gain/offset etc. After this, data
+ *can be written to SDRAM or can be connected to the image processing
+ *block such as IPIPE (on DM355/DM365 only).
+ *
+ *Features supported
+ * - MMAP IO
+ * - USERPTR IO
+ * - Capture using TVP5146 over BT.656
+ * - Support for interfacing decoders using sub device model
+ * - Work with DM365 or DM355 or DM6446 CCDC to do Raw Bayer
+ *   RGB/YUV data capture to SDRAM.
+ * - Chaining of Image Processor
+ * - SINGLE-SHOT mode
+ */
+
+#include linux/io.h
+#include linux/slab.h
+#include linux/init.h
+#include linux/module.h
+#include linux/version.h
+#include linux/interrupt.h
+#include linux/platform_device.h
+
+#include media/v4l2-common.h
+#include media/media-entity.h
+#include media/media-device.h
+#include media/davinci/vpfe_types.h
+
+#include vpfe_mc_capture.h
+
+static bool debug;

[PATCH 14/14] [media] davinci: vpfe: Add documentation

2012-09-14 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

Add documentation on the Davinci VPFE driver. Document the subdevs,
and private IOTCLs the driver implements

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
Cc: Rob Landley r...@landley.net
Cc: linux-...@vger.kernel.org
---
 Documentation/video4linux/davinci-vpfe-mc.txt |   95 +
 1 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/video4linux/davinci-vpfe-mc.txt

diff --git a/Documentation/video4linux/davinci-vpfe-mc.txt 
b/Documentation/video4linux/davinci-vpfe-mc.txt
new file mode 100644
index 000..9dfc4f9
--- /dev/null
+++ b/Documentation/video4linux/davinci-vpfe-mc.txt
@@ -0,0 +1,95 @@
+Davinci Video processing Front End (VPFE) driver
+
+Copyright (C) 2012 Texas Instruments Inc
+
+Contacts: Manjunath Hadli manjunath.ha...@ti.com
+
+
+Introduction
+
+
+This file documents the Texas Instruments Davinci Video processing Front End
+(VPFE) driver located under drivers/media/platform/davinci. The original driver
+exists for Davinci VPFE, which is now being changed to Media Controller
+Framework.
+
+Currently the driver has been successfully used on the following
+version of Davinci:
+
+   DM365/DM368
+
+The driver implements V4L2, Media controller and v4l2_subdev interfaces. 
Sensor,
+lens and flash drivers using the v4l2_subdev interface in the kernel are
+supported.
+
+
+Split to subdevs
+
+
+The Davinci VPFE is split into V4L2 subdevs, each of the blocks inside the VPFE
+having one subdev to represent it. Each of the subdevs provide a V4L2 subdev
+interface to userspace.
+
+   DAVINCI CCDC
+   DAVINCI PREVIEWER
+   DAVINCI RESIZER
+
+Each possible link in the VPFE is modeled by a link in the Media controller
+interface. For an example program see [1].
+
+
+Private IOCTLs
+==
+
+The Davinci Video processing Front End (VPFE) driver supports standard V4L2
+IOCTLs and controls where possible and practical. Much of the functions 
provided
+by the VPFE, however, does not fall under the standard IOCTL's.
+
+In general, there is a private ioctl for configuring each of the blocks
+containing hardware-dependent functions.
+
+The following private IOCTLs are supported:
+
+   VIDIOC_VPFE_CCDC_[S/G]_RAW_PARAMS
+   VIDIOC_VPFE_PRV_[S/G]_CONFIG
+   VIDIOC_VPFE_RSZ_[S/G]_CONFIG
+
+The parameter structures used by these ioctl's are described in
+include/linux/davinci_vpfe.h and include/linux/dm365_ccdc.h.
+
+The VIDIOC_VPFE_CCDC_S_RAW_PARAMS, VIDIOC_VPFE_PRV_S_CONFIG and
+VIDIOC_VPFE_RSZ_S_CONFIG are used to configure, enable and disable functions in
+the CCDC, preview and resizer blocks respectively. These IOCTL's control 
several
+functions in the blocks they control. VIDIOC_VPFE_CCDC_S_RAW_PARAMS IOCTL
+accepts a pointer to struct ccdc_config_params_raw as its argument. Similarly
+VIDIOC_VPFE_PRV_S_CONFIG accepts a pointer to struct vpfe_prev_config. And
+VIDIOC_VPFE_RSZ_S_CONFIG accepts a pointer to struct vpfe_rsz_config as its
+argument. Similarly VIDIOC_VPFE_CCDC_G_RAW_PARAMS, VIDIOC_VPFE_PRV_G_CONFIG and
+VIDIOC_VPFE_RSZ_G_CONFIG are used to get the current configuration set
+in the CCDC, preview and resizer blocks respectively.
+
+The detailed functions of the VPFE itself related to a given VPFE block is
+described in the Technical Reference Manuals (TRMs) --- see the end of the
+document for those.
+
+
+Technical reference manuals (TRMs) and other documentation
+==
+
+Davinci DM365 TRM:
+URL:http://www.ti.com/lit/ds/sprs457e/sprs457e.pdf
+Referenced MARCH 2009-REVISED JUNE 2011
+
+Davinci DM368 TRM:
+URL:http://www.ti.com/lit/ds/sprs668c/sprs668c.pdf
+Referenced APRIL 2010-REVISED JUNE 2011
+
+Davinci Video Processing Front End (VPFE) DM36x
+URL:http://www.ti.com/lit/ug/sprufg8c/sprufg8c.pdf
+
+
+References
+==
+
+[1] http://git.ideasonboard.org/?p=media-ctl.git;a=summary
+[2] include/linux/davinci_vpfe.h  include/linux/dm365_ccdc.h
-- 
1.7.4.1

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


[PATCH] davinci: vpif: capture/display: fix race condition

2012-09-14 Thread Prabhakar Lad
From: Lad, Prabhakar prabhakar@ti.com

channel_first_int[][] variable is used as a flag for the ISR,
This flag was being set after enabling the interrupts, There
where suitaions when the isr ocuurend even before the flag was set
dues to which it was causing the applicaiotn hang.
This patch sets  channel_first_int[][] flag just before enabling the
interrupt.

Reported-by: David Oleszkiewicz doles...@adsyscontrols.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Cc: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/davinci/vpif_capture.c |2 +-
 drivers/media/platform/davinci/vpif_display.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index 1b625b0..f64919b 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -339,6 +339,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
 * Set interrupt for both the fields in VPIF Register enable channel in
 * VPIF register
 */
+   channel_first_int[VPIF_VIDEO_INDEX][ch-channel_id] = 1;
if ((VPIF_CHANNEL0_VIDEO == ch-channel_id)) {
channel0_intr_assert();
channel0_intr_enable(1);
@@ -350,7 +351,6 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
channel1_intr_enable(1);
enable_channel1(1);
}
-   channel_first_int[VPIF_VIDEO_INDEX][ch-channel_id] = 1;
 
return 0;
 }
diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index 4a24848..523a840 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -302,6 +302,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
 
/* Set interrupt for both the fields in VPIF
Register enable channel in VPIF register */
+   channel_first_int[VPIF_VIDEO_INDEX][ch-channel_id] = 1;
if (VPIF_CHANNEL2_VIDEO == ch-channel_id) {
channel2_intr_assert();
channel2_intr_enable(1);
@@ -318,7 +319,6 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
if (vpif_config_data-ch3_clip_en)
channel3_clipping_enable(1);
}
-   channel_first_int[VPIF_VIDEO_INDEX][ch-channel_id] = 1;
 
return 0;
 }
-- 
1.7.4.1

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


Re: [PATCH] davinci: vpif: capture/display: fix race condition

2012-09-14 Thread Sergei Shtylyov
Hello.

On 09/14/2012 05:53 PM, Prabhakar Lad wrote:

 From: Lad, Prabhakar prabhakar@ti.com

 channel_first_int[][] variable is used as a flag for the ISR,
 This flag was being set after enabling the interrupts, There
 where suitaions when the isr ocuurend even before the flag was set

   s/suitaions/situations/, s/ocuurend/occured/

 dues to which it was causing the applicaiotn hang.

   Application.

 This patch sets  channel_first_int[][] flag just before enabling the
 interrupt.

 Reported-by: David Oleszkiewicz doles...@adsyscontrols.com
 Signed-off-by: Lad, Prabhakar prabhakar@ti.com
 Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
 Cc: Hans Verkuil hans.verk...@cisco.com

WBR, Sergei

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


[PATCH] davinci: vpif: remove unwanted header file inclusion

2012-09-14 Thread Prabhakar Lad
From: Hans Verkuil hans.verk...@cisco.com

Remove old videobuf-core.h includes.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpif_capture.h |1 -
 drivers/media/platform/davinci/vpif_display.h |1 -
 2 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.h 
b/drivers/media/platform/davinci/vpif_capture.h
index 3511510..15a06dc 100644
--- a/drivers/media/platform/davinci/vpif_capture.h
+++ b/drivers/media/platform/davinci/vpif_capture.h
@@ -25,7 +25,6 @@
 #include linux/videodev2.h
 #include media/v4l2-common.h
 #include media/v4l2-device.h
-#include media/videobuf-core.h
 #include media/videobuf2-dma-contig.h
 #include media/davinci/vpif_types.h
 
diff --git a/drivers/media/platform/davinci/vpif_display.h 
b/drivers/media/platform/davinci/vpif_display.h
index 8967ffb..dfda5bd 100644
--- a/drivers/media/platform/davinci/vpif_display.h
+++ b/drivers/media/platform/davinci/vpif_display.h
@@ -20,7 +20,6 @@
 #include linux/videodev2.h
 #include media/v4l2-common.h
 #include media/v4l2-device.h
-#include media/videobuf-core.h
 #include media/videobuf2-dma-contig.h
 #include media/davinci/vpif_types.h
 
-- 
1.7.4.1

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


Re: [PATCH 3/6] HID: picoLCD: Add support for CIR

2012-09-14 Thread Mauro Carvalho Chehab
Em 19-08-2012 14:32, Bruno Prémont escreveu:
 Implement support for picoLCD's CIR header using RC_CORE for decoding
 the IR event stream.
 
 Signed-off-by: Bruno Prémont bonb...@linux-vserver.org

Sorry for a late answer. I'm with a huge backlog due to KS/2012 workshop.

Acked-by: Mauro Carvalho Chehab mche...@redhat.com

 ---
  drivers/hid/hid-picolcd.h  |5 ++-
  drivers/hid/hid-picolcd_cir.c  |   95 
 +++-
  drivers/hid/hid-picolcd_core.c |3 +-
  3 files changed, 98 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/hid/hid-picolcd.h b/drivers/hid/hid-picolcd.h
 index dc4c795..240eb1c 100644
 --- a/drivers/hid/hid-picolcd.h
 +++ b/drivers/hid/hid-picolcd.h
 @@ -85,7 +85,9 @@ struct picolcd_data {
   /* input stuff */
   u8 pressed_keys[2];
   struct input_dev *input_keys;
 - struct input_dev *input_cir;
 +#ifdef CONFIG_HID_PICOLCD_CIR
 + struct rc_dev *rc_dev;
 +#endif
   unsigned short keycode[PICOLCD_KEYS];
  
  #ifdef CONFIG_HID_PICOLCD_FB
 @@ -114,6 +116,7 @@ struct picolcd_data {
   int status;
  #define PICOLCD_BOOTLOADER 1
  #define PICOLCD_FAILED 2
 +#define PICOLCD_CIR_SHUN 4
  };
  
  #ifdef CONFIG_HID_PICOLCD_FB
 diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
 index dc632c3..f38af30 100644
 --- a/drivers/hid/hid-picolcd_cir.c
 +++ b/drivers/hid/hid-picolcd_cir.c
 @@ -37,6 +37,7 @@
  #include linux/completion.h
  #include linux/uaccess.h
  #include linux/module.h
 +#include media/rc-core.h
  
  #include hid-picolcd.h
  
 @@ -44,18 +45,108 @@
  int picolcd_raw_cir(struct picolcd_data *data,
   struct hid_report *report, u8 *raw_data, int size)
  {
 - /* Need understanding of CIR data format to implement ... */
 + unsigned long flags;
 + int i, w, sz;
 + DEFINE_IR_RAW_EVENT(rawir);
 +
 + /* ignore if rc_dev is NULL or status is shunned */
 + spin_lock_irqsave(data-lock, flags);
 + if (data-rc_dev  (data-status  PICOLCD_CIR_SHUN)) {
 + spin_unlock_irqrestore(data-lock, flags);
 + return 1;
 + }
 + spin_unlock_irqrestore(data-lock, flags);
 +
 + /* PicoLCD USB packets contain 16-bit intervals in network order,
 +  * with value negated for pulse. Intervals are in microseconds.
 +  *
 +  * Note: some userspace LIRC code for PicoLCD says negated values
 +  * for space - is it a matter of IR chip? (pulse for my TSOP2236)
 +  *
 +  * In addition, the first interval seems to be around 15000 + base
 +  * interval for non-first report of IR data - thus the quirk below
 +  * to get RC_CODE to understand Sony and JVC remotes I have at hand
 +  */
 + sz = size  0 ? min((int)raw_data[0], size-1) : 0;
 + for (i = 0; i+1  sz; i += 2) {
 + init_ir_raw_event(rawir);
 + w = (raw_data[i]  8) | (raw_data[i+1]);
 + rawir.pulse = !!(w  0x8000);
 + rawir.duration = US_TO_NS(rawir.pulse ? (65536 - w) : w);
 + /* Quirk!! - see above */
 + if (i == 0  rawir.duration  1500)
 + rawir.duration -= 1500;
 + ir_raw_event_store(data-rc_dev, rawir);
 + }
 + ir_raw_event_handle(data-rc_dev);
 +
   return 1;
  }
  
 +static int picolcd_cir_open(struct rc_dev *dev)
 +{
 + struct picolcd_data *data = dev-priv;
 + unsigned long flags;
 +
 + spin_lock_irqsave(data-lock, flags);
 + data-status = ~PICOLCD_CIR_SHUN;
 + spin_unlock_irqrestore(data-lock, flags);
 + return 0;
 +}
 +
 +static void picolcd_cir_close(struct rc_dev *dev)
 +{
 + struct picolcd_data *data = dev-priv;
 + unsigned long flags;
 +
 + spin_lock_irqsave(data-lock, flags);
 + data-status |= PICOLCD_CIR_SHUN;
 + spin_unlock_irqrestore(data-lock, flags);
 +}
 +
  /* initialize CIR input device */
  int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)
  {
 - /* support not implemented yet */
 + struct rc_dev *rdev;
 + int ret = 0;
 +
 + rdev = rc_allocate_device();
 + if (!rdev)
 + return -ENOMEM;
 +
 + rdev-priv = data;
 + rdev-driver_type  = RC_DRIVER_IR_RAW;
 + rdev-allowed_protos   = RC_TYPE_ALL;
 + rdev-open = picolcd_cir_open;
 + rdev-close= picolcd_cir_close;
 + rdev-input_name   = data-hdev-name;
 + rdev-input_phys   = data-hdev-phys;
 + rdev-input_id.bustype = data-hdev-bus;
 + rdev-input_id.vendor  = data-hdev-vendor;
 + rdev-input_id.product = data-hdev-product;
 + rdev-input_id.version = data-hdev-version;
 + rdev-dev.parent   = data-hdev-dev;
 + rdev-driver_name  = PICOLCD_NAME;
 + rdev-map_name = RC_MAP_RC6_MCE;
 + rdev-timeout  = MS_TO_NS(100);
 + rdev-rx_resolution= US_TO_NS(1);
 +
 + ret = rc_register_device(rdev);
 + if (ret)
 + goto err;
 + data-rc_dev = 

how to crop/scale in mono-subdev camera sensor driver?

2012-09-14 Thread Nicolas THERY
Hello,

I'm studying how to support cropping and scaling (binning, skipping, digital
scaling if any) for different models for camera sensor drivers.  There seems to
be (at least) two kinds of sensor drivers:

1) The smiapp driver has 2 or 3 subdevs: pixel array - binning (- scaling).
It gives clients full control over the various ways of cropping and scaling 
thanks to the selection API.

2) The mt9p031 driver (and maybe others) has a single subdev.  Clients use the
obsolete SUBDEV_S_CROP ioctl for selecting a region of interest in the pixel
array and SUBDEV_S_FMT for setting the source pad mbus size.  If the mbus size
differs from the cropping rectangle size, scaling is enabled and the driver
decides internally how to combine skipping and binning to achieve the requested
scaling factors.

As SUBDEV_S_CROP is obsolete, I wonder whether it is okay to support cropping
and scaling in a mono-subdev sensor driver by (a) setting the cropping
rectangle with SUBDEV_S_SELECTION on the source pad, and (b) setting the
scaling factors via the source pad mbus size as in the mt9p031 driver?

Thanks in advance.

Best regards,
Nicolas--
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] drivers/media/platform/davinci/vpbe.c: Remove unused label and rename remaining labels

2012-09-14 Thread Peter Senna Tschudin
From: Peter Senna Tschudin peter.se...@gmail.com

Remove unused label and rename remaining labels

Signed-off-by: Peter Senna Tschudin peter.se...@gmail.com

---
Depends on patch [v2,7/8] drivers/media/platform/davinci/vpbe.c: Removes
useless kfree() - http://patchwork.linuxtv.org/patch/14307/

 drivers/media/platform/davinci/vpbe.c |   25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 1125a87..4d8e399 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -626,11 +626,11 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
vpbe_dev-dac_clk = clk_get(vpbe_dev-pdev, vpss_dac);
if (IS_ERR(vpbe_dev-dac_clk)) {
ret =  PTR_ERR(vpbe_dev-dac_clk);
-   goto vpbe_unlock;
+   goto fail_mutex_unlock;
}
if (clk_enable(vpbe_dev-dac_clk)) {
ret =  -ENODEV;
-   goto vpbe_unlock;
+   goto fail_mutex_unlock;
}
}
 
@@ -642,7 +642,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
if (ret) {
v4l2_err(dev-driver,
Unable to register v4l2 device.\n);
-   goto vpbe_fail_clock;
+   goto fail_clk_put;
}
v4l2_info(vpbe_dev-v4l2_dev, vpbe v4l2 device registered\n);
 
@@ -658,7 +658,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
v4l2_err(vpbe_dev-v4l2_dev,
vpbe unable to init venc sub device\n);
ret = -ENODEV;
-   goto vpbe_fail_v4l2_device;
+   goto fail_dev_unregister;
}
/* initialize osd device */
osd_device = vpbe_dev-osd_device;
@@ -669,7 +669,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
v4l2_err(vpbe_dev-v4l2_dev,
 unable to initialize the OSD device);
err = -ENOMEM;
-   goto vpbe_fail_v4l2_device;
+   goto fail_dev_unregister;
}
}
 
@@ -685,7 +685,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
v4l2_err(vpbe_dev-v4l2_dev,
unable to allocate memory for encoders sub devices);
ret = -ENOMEM;
-   goto vpbe_fail_v4l2_device;
+   goto fail_dev_unregister;
}
 
i2c_adap = i2c_get_adapter(vpbe_dev-cfg-i2c_adapter_id);
@@ -711,7 +711,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
  failed to register,
 enc_info-module_name);
ret = -ENODEV;
-   goto vpbe_fail_sd_register;
+   goto fail_kfree_encoders;
}
} else
v4l2_warn(vpbe_dev-v4l2_dev, non-i2c encoders
@@ -730,7 +730,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
 amplifier %s failed to register,
 amp_info-module_name);
ret = -ENODEV;
-   goto vpbe_fail_amp_register;
+   goto fail_kfree_encoders;
}
v4l2_info(vpbe_dev-v4l2_dev,
  v4l2 sub device %s registered\n,
@@ -770,15 +770,14 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
/* TBD handling of bootargs for default output and mode */
return 0;
 
-vpbe_fail_amp_register:
-vpbe_fail_sd_register:
+fail_kfree_encoders:
kfree(vpbe_dev-encoders);
-vpbe_fail_v4l2_device:
+fail_dev_unregister:
v4l2_device_unregister(vpbe_dev-v4l2_dev);
-vpbe_fail_clock:
+fail_clk_put:
if (strcmp(vpbe_dev-cfg-module_name, dm644x-vpbe-display) != 0)
clk_put(vpbe_dev-dac_clk);
-vpbe_unlock:
+fail_mutex_unlock:
mutex_unlock(vpbe_dev-lock);
return ret;
 }

--
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: [RFCv3 API PATCH 06/31] vivi/mem2mem_testdev: update to latest bus_info specification.

2012-09-14 Thread Sylwester Nawrocki

On 09/14/2012 12:57 PM, Hans Verkuil wrote:

Prefix bus_info with platform:.

Signed-off-by: Hans Verkuilhans.verk...@cisco.com


Looks good to me,

Acked-by: Sylwester Nawrocki s.nawro...@samsung.com


---
  drivers/media/platform/mem2mem_testdev.c |3 ++-
  drivers/media/platform/vivi.c|3 ++-
  2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mem2mem_testdev.c 
b/drivers/media/platform/mem2mem_testdev.c
index 0b496f3..74de642 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -430,7 +430,8 @@ static int vidioc_querycap(struct file *file, void *priv,
  {
strncpy(cap-driver, MEM2MEM_NAME, sizeof(cap-driver) - 1);
strncpy(cap-card, MEM2MEM_NAME, sizeof(cap-card) - 1);
-   strlcpy(cap-bus_info, MEM2MEM_NAME, sizeof(cap-bus_info));
+   snprintf(cap-bus_info, sizeof(cap-bus_info),
+   platform:%s, MEM2MEM_NAME);
cap-device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index a6351c4..7f3e6329 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -898,7 +898,8 @@ static int vidioc_querycap(struct file *file, void  *priv,

strcpy(cap-driver, vivi);
strcpy(cap-card, vivi);
-   strlcpy(cap-bus_info, dev-v4l2_dev.name, sizeof(cap-bus_info));
+   snprintf(cap-bus_info, sizeof(cap-bus_info),
+   platform:%s, dev-v4l2_dev.name);
cap-device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
V4L2_CAP_READWRITE;
cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;


--

Regards,
Sylwester
--
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: [RFCv3 API PATCH 28/31] Set vfl_dir for all display or m2m drivers.

2012-09-14 Thread Sylwester Nawrocki

On 09/14/2012 12:57 PM, Hans Verkuil wrote:

Signed-off-by: Hans Verkuilhans.verk...@cisco.com
---
  drivers/media/pci/ivtv/ivtv-streams.c |3 +++
  drivers/media/pci/zoran/zoran_card.c  |4 
  drivers/media/platform/coda.c |1 +
  drivers/media/platform/davinci/vpbe_display.c |1 +
  drivers/media/platform/davinci/vpif_display.c |1 +
  drivers/media/platform/m2m-deinterlace.c  |1 +
  drivers/media/platform/mem2mem_testdev.c  |1 +
  drivers/media/platform/mx2_emmaprp.c  |1 +
  drivers/media/platform/omap/omap_vout.c   |1 +
  drivers/media/platform/omap3isp/ispvideo.c|1 +
  drivers/media/platform/s5p-fimc/fimc-m2m.c|1 +
  drivers/media/platform/s5p-g2d/g2d.c  |1 +
  drivers/media/platform/s5p-jpeg/jpeg-core.c   |1 +
  drivers/media/platform/s5p-mfc/s5p_mfc.c  |1 +
  drivers/media/platform/s5p-tv/mixer_video.c   |1 +
  drivers/media/platform/sh_vou.c   |1 +
  drivers/media/usb/uvc/uvc_driver.c|2 ++


For drivers/media/platform/s5p-*,

Acked-by: Sylwester Nawrocki s.nawro...@samsung.com

--

Regards,
Sylwester
--
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: [RFCv3 API PATCH 31/31] Add vfl_dir field documentation.

2012-09-14 Thread Sylwester Nawrocki

On 09/14/2012 12:57 PM, Hans Verkuil wrote:

Signed-off-by: Hans Verkuilhans.verk...@cisco.com
---
  Documentation/video4linux/v4l2-framework.txt |9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Documentation/video4linux/v4l2-framework.txt 
b/Documentation/video4linux/v4l2-framework.txt
index 89318be..20f1c05 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -583,11 +583,18 @@ You should also set these fields:

  - name: set to something descriptive and unique.

+- vfl_dir: set to VFL_DIR_TX for output devices and VFL_DIR_M2M for mem2mem
+  (codec) devices.
+


No need to document VFL_DIR_RX ?


  - fops: set to the v4l2_file_operations struct.

  - ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance
(highly recommended to use this and it might become compulsory in the
-  future!), then set this to your v4l2_ioctl_ops struct.
+  future!), then set this to your v4l2_ioctl_ops struct. The vfl_type and
+  vfl_dir fields are used to disable ops that do not match the type/dir
+  combination. E.g. VBI ops are disabled for non-VBI nodes, and output ops
+  are disabled for a capture device. This makes it possible to provide
+  just one v4l2_ioctl_ops struct for both vbi and video nodes.

  - lock: leave to NULL if you want to do all the locking in the driver.
Otherwise you give it a pointer to a struct mutex_lock and before the


--

Regards,
Sylwester
--
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: [RFCv3 API PATCH 31/31] Add vfl_dir field documentation.

2012-09-14 Thread Hans Verkuil
On Fri September 14 2012 19:34:56 Sylwester Nawrocki wrote:
 On 09/14/2012 12:57 PM, Hans Verkuil wrote:
  Signed-off-by: Hans Verkuilhans.verk...@cisco.com
  ---
Documentation/video4linux/v4l2-framework.txt |9 -
1 file changed, 8 insertions(+), 1 deletion(-)
 
  diff --git a/Documentation/video4linux/v4l2-framework.txt 
  b/Documentation/video4linux/v4l2-framework.txt
  index 89318be..20f1c05 100644
  --- a/Documentation/video4linux/v4l2-framework.txt
  +++ b/Documentation/video4linux/v4l2-framework.txt
  @@ -583,11 +583,18 @@ You should also set these fields:
 
- name: set to something descriptive and unique.
 
  +- vfl_dir: set to VFL_DIR_TX for output devices and VFL_DIR_M2M for mem2mem
  +  (codec) devices.
  +
 
 No need to document VFL_DIR_RX ?

Oops. Just because it is the default doesn't mean that I shouldn't document it.

I'll change this to:

- vfl_dir: set this to VFL_DIR_RX for capture devices (VFL_DIR_RX has value 0,
  so this is normally already the default), set to VFL_DIR_TX for output
  devices and VFL_DIR_M2M for mem2mem (codec) devices.

Thanks for all the reviews/acks!

Regards,

Hans

 
- fops: set to the v4l2_file_operations struct.
 
- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance
  (highly recommended to use this and it might become compulsory in the
  -  future!), then set this to your v4l2_ioctl_ops struct.
  +  future!), then set this to your v4l2_ioctl_ops struct. The vfl_type and
  +  vfl_dir fields are used to disable ops that do not match the type/dir
  +  combination. E.g. VBI ops are disabled for non-VBI nodes, and output ops
  +  are disabled for a capture device. This makes it possible to provide
  +  just one v4l2_ioctl_ops struct for both vbi and video nodes.
 
- lock: leave to NULL if you want to do all the locking in the driver.
  Otherwise you give it a pointer to a struct mutex_lock and before the
 
 --
 
 Regards,
 Sylwester
 --
 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


cron job: media_tree daily build: ERRORS

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

Results of the daily build of media_tree:

date:Fri Sep 14 19:02:16 CEST 2012
git hash:780d61704cf62a51c06c0ca8210d0282591e00b2
gcc version:  i686-linux-gcc (GCC) 4.7.1
host hardware:x86_64
host os:  3.4.07-marune

linux-git-arm-eabi-davinci: WARNINGS
linux-git-arm-eabi-exynos: OK
linux-git-arm-eabi-omap: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: WARNINGS
linux-git-mips: WARNINGS
linux-git-powerpc64: WARNINGS
linux-git-x86_64: WARNINGS
linux-2.6.31.12-x86_64: ERRORS
linux-2.6.32.6-x86_64: ERRORS
linux-2.6.33-x86_64: ERRORS
linux-2.6.34-x86_64: ERRORS
linux-2.6.35.3-x86_64: ERRORS
linux-2.6.36-x86_64: ERRORS
linux-2.6.37-x86_64: ERRORS
linux-2.6.38.2-x86_64: ERRORS
linux-2.6.39.1-x86_64: ERRORS
linux-3.0-x86_64: ERRORS
linux-3.1-x86_64: ERRORS
linux-3.2.1-x86_64: ERRORS
linux-3.3-x86_64: ERRORS
linux-3.4-x86_64: ERRORS
linux-3.5-x86_64: WARNINGS
linux-3.6-rc2-x86_64: WARNINGS
linux-2.6.31.12-i686: ERRORS
linux-2.6.32.6-i686: ERRORS
linux-2.6.33-i686: ERRORS
linux-2.6.34-i686: ERRORS
linux-2.6.35.3-i686: ERRORS
linux-2.6.36-i686: ERRORS
linux-2.6.37-i686: ERRORS
linux-2.6.38.2-i686: ERRORS
linux-2.6.39.1-i686: ERRORS
linux-3.0-i686: ERRORS
linux-3.1-i686: ERRORS
linux-3.2.1-i686: ERRORS
linux-3.3-i686: ERRORS
linux-3.4-i686: ERRORS
linux-3.5-i686: WARNINGS
linux-3.6-rc2-i686: WARNINGS
apps: WARNINGS
spec-git: WARNINGS
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The 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: [PATCH 3/4] videobuf2-dma-streaming: new videobuf2 memory allocator

2012-09-14 Thread Ezequiel Garcia
Hi Jon,

On Thu, Sep 13, 2012 at 2:54 PM, Jonathan Corbet cor...@lwn.net wrote:


 Well, there is some documentation here:

 https://lwn.net/Articles/447435/


I thank you for this. It really helped me getting started on videobuf2.

 This reminds me that I've always meant to turn it into something to put
 into Documentation/.  I'll try to get to that soon.


Yes, that's something many of us will appreciate A LOT.

Perhaps we could start with some skeleton documentation and then build
from there.
I maybe naive, but I think that way other developers might add little
contributions.

Regards,
Ezequiel.

PS: I wish I had some time to do it myself.
--
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: [RFCv3 API PATCH 15/31] v4l2-core: Add new V4L2_CAP_MONOTONIC_TS capability.

2012-09-14 Thread Sakari Ailus

Hi Hans,

Thanks for the patch.

Hans Verkuil wrote:
...

--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -290,6 +290,7 @@ struct v4l2_capability {
  #define V4L2_CAP_ASYNCIO0x0200  /* async I/O */
  #define V4L2_CAP_STREAMING  0x0400  /* streaming I/O ioctls */

+#define V4L2_CAP_MONOTONIC_TS   0x4000  /* uses monotonic 
timestamps */
  #define V4L2_CAP_DEVICE_CAPS0x8000  /* sets device 
capabilities field */


I have to say I'm still not a big fan of this new capability flag.

I had a quick discussion with Laurent, and what he suggested was to use 
the kernel version to figure out the type of the timestamp. The drivers 
that use the monotonic time right now wouldn't be affected by the new 
flag on older kernels. If we've decided we're going to switch to 
monotonic time anyway, why not just change all the drivers now and 
forget the capability flag.


Instead of a capability flag, the applications would know the type of 
the timestamp based on the kernel version. In the end we wouldn't be 
left with a useless flag that every single driver would have to set.


It's true that there are some 70 such drivers that need to be converted 
but it's still a trivial, mechanical task. It would be even easier to 
implement a helper function called e.g. v4l2_buffer_timestamp() so that 
every user wouldn't have to convert timespec to timeval.


As a result we'd also have a very short transition period to the 
timestamps we prefer.


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: [RFCv3 API PATCH 15/31] v4l2-core: Add new V4L2_CAP_MONOTONIC_TS capability.

2012-09-14 Thread Rémi Denis-Courmont
Le vendredi 14 septembre 2012 23:25:01, Sakari Ailus a écrit :
 I had a quick discussion with Laurent, and what he suggested was to use
 the kernel version to figure out the type of the timestamp. The drivers
 that use the monotonic time right now wouldn't be affected by the new
 flag on older kernels. If we've decided we're going to switch to
 monotonic time anyway, why not just change all the drivers now and
 forget the capability flag.

That does not work In Real Life.

People do port old drivers forward to new kernels.
People do port new drivers back to old kernels

User space needs a flag is needed. Full point.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
--
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: how to crop/scale in mono-subdev camera sensor driver?

2012-09-14 Thread Sylwester Nawrocki
Hi,

On 09/14/2012 05:00 PM, Nicolas THERY wrote:
 Hello,
 
 I'm studying how to support cropping and scaling (binning, skipping, digital
 scaling if any) for different models for camera sensor drivers.  There seems 
 to
 be (at least) two kinds of sensor drivers:
 
 1) The smiapp driver has 2 or 3 subdevs: pixel array -  binning (-  
 scaling).
 It gives clients full control over the various ways of cropping and scaling
 thanks to the selection API.
 
 2) The mt9p031 driver (and maybe others) has a single subdev.  Clients use the
 obsolete SUBDEV_S_CROP ioctl for selecting a region of interest in the pixel
 array and SUBDEV_S_FMT for setting the source pad mbus size.  If the mbus size
 differs from the cropping rectangle size, scaling is enabled and the driver
 decides internally how to combine skipping and binning to achieve the 
 requested
 scaling factors.
 
 As SUBDEV_S_CROP is obsolete, I wonder whether it is okay to support cropping
 and scaling in a mono-subdev sensor driver by (a) setting the cropping
 rectangle with SUBDEV_S_SELECTION on the source pad, and (b) setting the
 scaling factors via the source pad mbus size as in the mt9p031 driver?

Cc: Sakari, Laurent

AFAICT in a single subdev with one pad configuration your steps as above 
are valid, i.e. crop rectangle can be set with 
VIDIOC_SUBDEV_S_SELECTION(V4L2_SEL_TGT_CROP) and the sensor's output 
resolution with VIDIOC_SUBDEV_S_FMT.

I guess documentation [1] wasn't clear enough about that ?

The subdev crop ioctls are deprecated in favour of the selection API, so
now VIDIOC_SUBDEV_G/S_SELECTION ioctls and corresponding subdev ops needs 
to be used anywhere you would have used SUBDEV_G/S_CROP before.

This reminds me there are still a few drivers that need to be converted
to use set/get_selection subdev pad level ops, rather than set/get_crop.

[1] http://linuxtv.org/downloads/v4l-dvb-apis/subdev.html

--

Regards,
Sylwester
--
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: [RFCv3 API PATCH 15/31] v4l2-core: Add new V4L2_CAP_MONOTONIC_TS capability.

2012-09-14 Thread Sakari Ailus

Hi Rémi,

Rémi Denis-Courmont wrote:

Le vendredi 14 septembre 2012 23:25:01, Sakari Ailus a écrit :

I had a quick discussion with Laurent, and what he suggested was to use
the kernel version to figure out the type of the timestamp. The drivers
that use the monotonic time right now wouldn't be affected by the new
flag on older kernels. If we've decided we're going to switch to
monotonic time anyway, why not just change all the drivers now and
forget the capability flag.


That does not work In Real Life.

People do port old drivers forward to new kernels.
People do port new drivers back to old kernels


Why would you port a driver from an old kernel to a new kernel? Or are 
you talking about out-of-tree drivers?


If you do port drivers across different kernel versions I guess you're 
supposed to use the appropriate interfaces for those kernels, too. Using 
a helper function helps here, so compiling a backported driver would 
fail w/o the helper function that produces the timestamp, forcing the 
backporter to notice the situation.


Anyway, I don't have a very strict opinion on this, so I'm okay with the 
flag, too, but I personally simply don't think it's the best choice we 
can make now. Also, without converting the drivers now the user space 
must live with different kinds of timestamps much longer.


Cc Laurent and Hans.

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


[PATCH v2] omap3isp: Use monotonic timestamps for statistics buffers

2012-09-14 Thread Laurent Pinchart
V4L2 buffers use the monotonic clock, while statistics buffers use wall
time. This makes it difficult to correlate video frames and statistics.

Switch statistics buffers to the monotonic clock to fix this, and
replace struct timeval with struct timespec.

Reported-by: Antoine Reversat a.rever...@gmail.com
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/platform/omap3isp/ispstat.c |2 +-
 drivers/media/platform/omap3isp/ispstat.h |2 +-
 include/linux/omap3isp.h  |7 ++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/omap3isp/ispstat.c 
b/drivers/media/platform/omap3isp/ispstat.c
index b8640be..bb21c4e 100644
--- a/drivers/media/platform/omap3isp/ispstat.c
+++ b/drivers/media/platform/omap3isp/ispstat.c
@@ -256,7 +256,7 @@ static int isp_stat_buf_queue(struct ispstat *stat)
if (!stat-active_buf)
return STAT_NO_BUF;
 
-   do_gettimeofday(stat-active_buf-ts);
+   ktime_get_ts(stat-active_buf-ts);
 
stat-active_buf-buf_size = stat-buf_size;
if (isp_stat_buf_check_magic(stat, stat-active_buf)) {
diff --git a/drivers/media/platform/omap3isp/ispstat.h 
b/drivers/media/platform/omap3isp/ispstat.h
index 9b7c865..8221d0c 100644
--- a/drivers/media/platform/omap3isp/ispstat.h
+++ b/drivers/media/platform/omap3isp/ispstat.h
@@ -50,7 +50,7 @@ struct ispstat_buffer {
struct iovm_struct *iovm;
void *virt_addr;
dma_addr_t dma_addr;
-   struct timeval ts;
+   struct timespec ts;
u32 buf_size;
u32 frame_number;
u16 config_counter;
diff --git a/include/linux/omap3isp.h b/include/linux/omap3isp.h
index c090cf9..263a0c0 100644
--- a/include/linux/omap3isp.h
+++ b/include/linux/omap3isp.h
@@ -27,6 +27,11 @@
 #ifndef OMAP3_ISP_USER_H
 #define OMAP3_ISP_USER_H
 
+#ifdef __KERNEL__
+#include linux/time.h /* need struct timespec */
+#else
+#include sys/time.h
+#endif
 #include linux/types.h
 #include linux/videodev2.h
 
@@ -164,7 +169,7 @@ struct omap3isp_h3a_aewb_config {
  * @config_counter: Number of the configuration associated with the data.
  */
 struct omap3isp_stat_data {
-   struct timeval ts;
+   struct timespec ts;
void __user *buf;
__u32 buf_size;
__u16 frame_number;
-- 
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: Improving ov7670 sensor driver.

2012-09-14 Thread Laurent Pinchart
Hi Javier,

On Thursday 13 September 2012 11:48:17 javier Martin wrote:
 Hi,
 our new i.MX27 based platform (Visstrim-SM20) uses an ov7675 sensor
 attached to the CSI interface. Apparently, this sensor is fully
 compatible with the old ov7670. For this reason, it seems rather
 sensible that they should share the same driver: ov7670.c
 One of the challenges we have to face is that capture video support
 for our platform is mx2_camera.c, which is a soc-camera host driver;
 while ov7670.c was developed for being used as part of a more complex
 video card.
 
 Here is the list of current users of ov7670:
 
 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/gspca/ov519.c
 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/gspca/sn9c20x.c
 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/gspca/vc032x.c
 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/via-camera.c
 http://lxr.linux.no/#linux+v3.5.3/drivers/media/video/marvell-ccic/mcam-core
 .c
 
 These are basically the improvements we need to make to this driver in
 order to satisfy our needs:
 
 1.- Adapt v4l2 controls to the subvevice control framework, with a
 proper ctrl handler, etc...
 2.- Add the possibility to bypass PLL and clkrc preescaler.
 3.- Adjust vstart/vstop in order to remove an horizontal green line.
 4.- Disable pixclk during horizontal blanking.
 5.- min_height, min_width should be respected in try_fmt().
 6.- Pass platform data when used with a soc-camera host driver.
 7.- Add V4L2_CID_POWER_LINE_FREQUENCY ctrl.

8. Make sure it still works when used with a non soc-camera bridge.

That's the tricky part. I've spent time working on this for the ov772x driver 
(albeit in the other direction, making it usable with a non soc-camera 
bridge). You can find work-in-progress hacks at

http://git.linuxtv.org/pinchartl/media.git/shortlog/refs/heads/omap3isp-
sensors-board

The basic idea is that the soc-camera platform data structure needs to be 
split into a generic device part (currently called soc_camera_pdtata, which 
should be renamed to something not related to soc-camera), and a soc-camera 
specific structure. The device should only see the device part, and the soc-
camera framework will get the host part. That's currently not implemented.

-- 
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: [PATCHSET] kthread_worker: reimplement flush_kthread_work() to allow freeing during execution

2012-09-14 Thread Colin Cross
On Thu, Jul 19, 2012 at 2:15 PM, Tejun Heo t...@kernel.org wrote:
 Hello,

 kthread_worker was introduced together with concurrency managed
 workqueue to serve workqueue users which need a special dedicated
 worker - e.g. RT scheduling.  This is minimal queue / flush / flush
 all iterface on top of kthread and each provided interface matches the
 workqueue counterpart so that switching isn't difficult.

 However, one noticeable difference was that kthread_worker doesn't
 allow a work item to be freed while being executed.  The intention was
 to keep the code simpler but it didn't really and the restriction is
 subtle and does prevent some valid use cases.

 This two-patch series reimplements flush_kthread_work() so that it
 uses an extra work item for flushing.  While this takes a bit more
 lines, this is easier to understand and removes the annoying
 difference.

 This patchset contains the following two patches.

  0001-kthread_worker-reorganize-to-prepare-for-flush_kthre.patch
  0002-kthread_worker-reimplement-flush_kthread_work-to-all.patch

 The first one is a prep patch which makes no functional changes.  The
 second reimplements flush_kthread_work().

 All current kthread_worker users are cc'd.  If no one objects, I'll
 push it through the workqueue branch.  This patchset is also available
 in the following git branch.

  git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git 
 review-kthread_worker-flush

 diffstat follows.  Thanks.

  include/linux/kthread.h |8 +---
  kernel/kthread.c|   86 
 +++-
  2 files changed, 52 insertions(+), 42 deletions(-)

 --
 tejun

This patch set fixes a reproducible crash I'm seeing on a 3.4.10
kernel.  flush_kthread_worker (which is different from
flush_kthread_work) is initializing a kthread_work and a completion on
the stack, then queuing it and calling wait_for_completion.  Once the
completion is signaled, flush_kthread_worker exits and the stack
region used by the kthread_work may be immediately reused by another
object on the stack, but kthread_worker_fn continues accessing its
work pointer:
work-func(work); - calls complete,
effectively frees work
smp_wmb();  /* wmb worker-b0 paired with flush-b1 */
work-done_seq = work-queue_seq;   - overwrites a
new stack object
smp_mb();   /* mb worker-b1 paired with flush-b0 */
if (atomic_read(work-flushing))
wake_up_all(work-done);  - or crashes here

These patches fix the problem by not accessing work after work-func
is called, and should be backported to stable.  They apply cleanly to
3.4.10.  Upstream commits are 9a2e03d8ed518a61154f18d83d6466628e519f94
and 46f3d976213452350f9d10b0c2780c2681f7075b.
--
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