Re: [PATCH v6 3/7] media: soc-camera: switch I2C subdevice drivers to use v4l2-clk

2013-03-18 Thread Hans Verkuil
On Fri March 15 2013 22:27:49 Guennadi Liakhovetski wrote:
 Instead of centrally enabling and disabling subdevice master clocks in
 soc-camera core, let subdevice drivers do that themselves, using the
 V4L2 clock API and soc-camera convenience wrappers.
 
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---
 
 v6: clock name update
 
  drivers/media/i2c/soc_camera/imx074.c  |   18 ++-
  drivers/media/i2c/soc_camera/mt9m001.c |   17 ++-
  drivers/media/i2c/soc_camera/mt9m111.c |   20 ++-
  drivers/media/i2c/soc_camera/mt9t031.c |   19 ++-
  drivers/media/i2c/soc_camera/mt9t112.c |   19 ++-
  drivers/media/i2c/soc_camera/mt9v022.c |   17 ++-
  drivers/media/i2c/soc_camera/ov2640.c  |   19 ++-
  drivers/media/i2c/soc_camera/ov5642.c  |   20 ++-
  drivers/media/i2c/soc_camera/ov6650.c  |   17 ++-
  drivers/media/i2c/soc_camera/ov772x.c  |   15 ++-
  drivers/media/i2c/soc_camera/ov9640.c  |   17 ++-
  drivers/media/i2c/soc_camera/ov9640.h  |1 +
  drivers/media/i2c/soc_camera/ov9740.c  |   18 ++-
  drivers/media/i2c/soc_camera/rj54n1cb0c.c  |   17 ++-
  drivers/media/i2c/soc_camera/tw9910.c  |   18 ++-
  drivers/media/platform/soc_camera/soc_camera.c |  172 
 +++-
  .../platform/soc_camera/soc_camera_platform.c  |2 +-
  include/media/soc_camera.h |   13 +-
  18 files changed, 355 insertions(+), 84 deletions(-)
 
 diff --git a/drivers/media/i2c/soc_camera/imx074.c 
 b/drivers/media/i2c/soc_camera/imx074.c
 index a2a5cbb..cee5345 100644
 --- a/drivers/media/i2c/soc_camera/imx074.c
 +++ b/drivers/media/i2c/soc_camera/imx074.c
 @@ -18,6 +18,7 @@
  #include linux/module.h
  
  #include media/soc_camera.h
 +#include media/v4l2-clk.h
  #include media/v4l2-subdev.h
  #include media/v4l2-chip-ident.h
  
 @@ -77,6 +78,7 @@ struct imx074_datafmt {
  struct imx074 {
   struct v4l2_subdev  subdev;
   const struct imx074_datafmt *fmt;
 + struct v4l2_clk *clk;
  };
  
  static const struct imx074_datafmt imx074_colour_fmts[] = {
 @@ -272,8 +274,9 @@ static int imx074_s_power(struct v4l2_subdev *sd, int on)
  {
   struct i2c_client *client = v4l2_get_subdevdata(sd);
   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 + struct imx074 *priv = to_imx074(client);
  
 - return soc_camera_set_power(client-dev, ssdd, on);
 + return soc_camera_set_power(client-dev, ssdd, priv-clk, on);
  }
  
  static int imx074_g_mbus_config(struct v4l2_subdev *sd,
 @@ -431,6 +434,7 @@ static int imx074_probe(struct i2c_client *client,
   struct imx074 *priv;
   struct i2c_adapter *adapter = to_i2c_adapter(client-dev.parent);
   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 + int ret;
  
   if (!ssdd) {
   dev_err(client-dev, IMX074: missing platform data!\n);
 @@ -451,13 +455,23 @@ static int imx074_probe(struct i2c_client *client,
  
   priv-fmt   = imx074_colour_fmts[0];
  
 - return imx074_video_probe(client);
 + priv-clk = v4l2_clk_get(priv-subdev, mclk);
 + if (IS_ERR(priv-clk))
 + return PTR_ERR(priv-clk);
 +
 + ret = imx074_video_probe(client);
 + if (ret  0)
 + v4l2_clk_put(priv-clk);
 +

I feel uneasy about this. It's not the clock part as such but the fact that
assumptions are made about the usage of this sensor driver. It basically
comes down to the fact that these drivers are *still* tied to the soc-camera
framework. I think I am going to work on this in a few weeks time to cut
these drivers loose from soc-camera. We discussed how to do that in the past.

The whole point of the subdev API is to make drivers independent of bridge
drivers, and these soc-camera subdev drivers are the big exception and they
stick out like a sore thumb.

Anyway, w.r.t. the clock use: what happens if these drivers are used in e.g.
a USB webcam driver? In that case there probably won't be a clock involved
(well, there is one, but that is likely to be setup by the firmware/hardware
itself).

Wouldn't it be better if the clock name is passed on through the platform data
(or device tree)? And if no clock name was specified, then there is no need to
get a clock either and the driver can assume that it will always have a clock.
That would solve this problem when this sensor driver is no longer soc-camera
dependent.

Sorry if this was discussed in earlier patches, I haven't been following this
very closely before.

Regards,

Hans

 + return ret;
  }
  
  static int imx074_remove(struct i2c_client *client)
  {
   struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 + struct imx074 *priv = to_imx074(client);
  
 + v4l2_clk_put(priv-clk);
   if (ssdd-free_bus)
   

Re: [RFC V1 2/8] smi2021: Add smi2021_main.c

2013-03-18 Thread Hans Verkuil
Hi Jon Arne,

Here is my review of this driver.

Regards,

Hans

On Thu March 14 2013 15:06:58 Jon Arne Jørgensen wrote:
 This is the core of the smi2021 module.
 It will register the module with the kernel, and register the
 usb probe function.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_main.c | 339 
 +++
  1 file changed, 339 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_main.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_main.c 
 b/drivers/media/usb/smi2021/smi2021_main.c
 new file mode 100644
 index 000..cc600e7
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_main.c
 @@ -0,0 +1,339 @@
 +/***
 + * smi2021_main.c
   *
 + *   
   *
 + * USB Driver for SMI2021 - EasyCAP  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021
 + * http://code.google.com/p/easycap-somagic-linux/
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com
 + *
 + */
 +
 +#include smi2021.h
 +
 +#define VENDOR_ID 0x1c88
 +
 +static unsigned int imput;
 +module_param(imput, int, 0644);
 +MODULE_PARM_DESC(input, Set default input);
 +
 +MODULE_LICENSE(GPL);
 +MODULE_AUTHOR(Jon Arne Jørgensen jonjon.arnearne--a.t--gmail.com);
 +MODULE_DESCRIPTION(SMI2021 - EasyCap);
 +MODULE_VERSION(SMI2021_DRIVER_VERSION);
 +
 +
 +struct usb_device_id smi2021_usb_device_id_table[] = {

Should be static const

 + { USB_DEVICE(VENDOR_ID, 0x003c) },
 + { USB_DEVICE(VENDOR_ID, 0x003d) },
 + { USB_DEVICE(VENDOR_ID, 0x003e) },
 + { USB_DEVICE(VENDOR_ID, 0x003f) },
 + { }
 +};
 +
 +MODULE_DEVICE_TABLE(usb, smi2021_usb_device_id_table);
 +
 +static unsigned short saa7113_addrs[] = {
 + 0x4a,
 + I2C_CLIENT_END
 +};

Don't use this. See below for more info.

 +
 +/**/
 +/*   
  */
 +/*  Write to saa7113 
  */
 +/*   
  */
 +/**/
 +
 +inline int transfer_usb_ctrl(struct smi2021_dev *dev, u8 *data, int len)
 +{
 + return usb_control_msg(dev-udev, usb_sndctrlpipe(dev-udev, 0x00),
 + 0x01, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 + 0x0b, 0x00,
 + data, len, 1000);
 +}
 +
 +int smi2021_write_reg(struct smi2021_dev *dev, u8 addr, u16 reg, u8 val)
 +{
 + int rc;
 + u8 snd_data[8];
 +
 + memset(snd_data, 0x00, 8);
 +
 + snd_data[SMI2021_CTRL_HEAD] = 0x0b;
 + snd_data[SMI2021_CTRL_ADDR] = addr;
 + snd_data[SMI2021_CTRL_DATA_SIZE] = 0x01;
 +
 + if (addr) {
 + /* This is I2C data for the saa7113 chip */
 + snd_data[SMI2021_CTRL_BM_DATA_TYPE] = 0xc0;
 + snd_data[SMI2021_CTRL_BM_DATA_OFFSET] = 0x01;
 +
 + snd_data[SMI2021_CTRL_I2C_REG] = reg;
 + snd_data[SMI2021_CTRL_I2C_VAL] = val;
 + } else {
 + /* This is register settings for the smi2021 chip */
 + snd_data[SMI2021_CTRL_BM_DATA_OFFSET] = 0x82;
 +
 + snd_data[SMI2021_CTRL_REG_HI] = __cpu_to_be16(reg)  8;
 + snd_data[SMI2021_CTRL_REG_LO] = __cpu_to_be16(reg);

This looks really weird. On a little endian system REG_HI is now initialized
with the LSB, not MSB and the other way around on a big endian system.
The _cpu_to_be16 

Re: [RFC V1 3/8] smi2021: Add smi2021_i2c.c

2013-03-18 Thread Hans Verkuil
On Thu March 14 2013 15:06:59 Jon Arne Jørgensen wrote:
 This file is responsible for registering the device
 with the kernel i2c subsystem.
 v4l2 talks to the saa7113 chip of the device via i2c.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_i2c.c | 160 
 
  1 file changed, 160 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_i2c.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_i2c.c 
 b/drivers/media/usb/smi2021/smi2021_i2c.c
 new file mode 100644
 index 000..5b6f3f5
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_i2c.c
 @@ -0,0 +1,160 @@
 +/***
 + * smi2021_i2c.c 
   *
 + *   
   *
 + * USB Driver for SMI2021 - EasyCAP  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021
 + * http://code.google.com/p/easycap-somagic-linux/
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com
 + *
 + */
 +
 +#include smi2021.h
 +
 +/* The device will not return the chip_name on address 0x00.
 + * But the saa7115 i2c driver needs the chip id to match f7113
 + * if we want to use it,
 + * so we have to fake the return of this value
 + */
 +
 +static char chip_id[] = { 'x', 255, 55, 49, 49, 115, 0 };
 +static int id_ptr;

Don't do this! Instead modify saa7115.c and add a new chip_id (the name of
this saa7113 clone) and specify that in v4l2_i2c_new_subdev instead of 
saa7113.
The saa7115.c driver should skip the chip ID test if that name is specified.

Then you don't need this hack anymore and everything will look much cleaner.

 +
 +static unsigned int i2c_debug;
 +module_param(i2c_debug, int, 0644);
 +MODULE_PARM_DESC(i2c_debug, enable debug messages [i2c]);
 +
 +#define dprint_i2c(fmt, args...) \
 +do { \
 + if (i2c_debug)  \
 + pr_debug(smi2021[i2c]::%s:  fmt, __func__, ##args);   \
 +} while (0)
 +
 +
 +static int i2c_xfer(struct i2c_adapter *i2c_adap,
 + struct i2c_msg msgs[], int num)
 +{
 + struct smi2021_dev *dev = i2c_adap-algo_data;
 +
 + switch (num) {
 + case 2: { /* Read reg */
 + if (msgs[0].len != 1 || msgs[1].len != 1) {
 + dprint_i2c(both messages must be 1 byte\n);
 + goto err_out;
 +
 + if ((msgs[1].flags  I2C_M_RD) != I2C_M_RD)
 + dprint_i2c(last message should have rd flag\n);
 + goto err_out;
 + }
 +
 + if (msgs[0].buf[0] == 0) {
 + msgs[1].buf[0] = chip_id[id_ptr];
 + if (chip_id[id_ptr] != 0)
 + id_ptr += 1;
 + } else {
 + smi2021_read_reg(dev, msgs[0].addr, msgs[0].buf[0],
 + msgs[1].buf);
 + }
 + break;
 + }
 + case 1: { /* Write reg */
 + if (msgs[0].len == 0) {
 + break;
 + } else if (msgs[0].len != 2) {
 + dprint_i2c(unsupported len\n);
 + goto err_out;
 + }
 + if (msgs[0].buf[0] == 0) {
 + /* We don't handle writing to addr 0x00 */
 + break;
 + }
 +
 + smi2021_write_reg(dev, msgs[0].addr, msgs[0].buf[0],
 + msgs[0].buf[1]);
 + break;
 + }
 + default: {
 + 

Re: [RFC V1 4/8] smi2021: Add smi2021_v4l2.c

2013-03-18 Thread Hans Verkuil
On Thu March 14 2013 15:07:00 Jon Arne Jørgensen wrote:
 This file is responsible for registering the device with the v4l2 subsystem,
 and the communication with v4l2.
 Most of the v4l2 ioctls are just passed on to vidbuf2.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_v4l2.c | 566 
 +++
  1 file changed, 566 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_v4l2.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_v4l2.c 
 b/drivers/media/usb/smi2021/smi2021_v4l2.c
 new file mode 100644
 index 000..d402093
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_v4l2.c
 @@ -0,0 +1,566 @@
 +/***
 + * smi2021_v4l2.c
   *
 + *   
   *
 + * USB Driver for smi2021 - EasyCap  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021
 + * http://code.google.com/p/easycap-somagic-linux/
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com
 + *
 + */
 +
 +#include smi2021.h
 +
 +static struct smi2021_fmt format[] = {

const.

 + {
 + .name = 16bpp YU2, 4:2:2, packed,
 + .fourcc = V4L2_PIX_FMT_UYVY,
 + .depth = 16,
 + }
 +};
 +
 +static const int inputs = 2;
 +static struct smi2021_input input[] = {
 + {
 + .name = Composite,
 + .type = SAA7115_COMPOSITE0,
 + },
 + {
 + .name = S-Video,
 + .type = SAA7115_SVIDEO1,
 + }
 +};

const

 +
 +static void smi2021_set_input(struct smi2021_dev *dev)
 +{
 + if (dev-udev == NULL)
 + return;

These udev tests are unnecessary. Once the video_unregister is called no
new ioctls or file operations (except release()) can ever be issued.

 +
 + if (dev-ctl_input = inputs) {
 + smi2021_err(BUG: ctl_input to big!\n);
 + return;
 + }
 +
 + v4l2_device_call_all(dev-v4l2_dev, 0, video, s_routing,
 + input[dev-ctl_input].type, 0, 0);
 +}
 +
 +static int smi2021_start_streaming(struct smi2021_dev *dev)
 +{
 + u8 data[2];
 + int i, rc = 0;

Extra newline.

 + data[0] = 0x01;
 + data[1] = 0x05;
 +
 + if (!dev-udev)
 + return -ENODEV;
 +
 + dev-sync_state = HSYNC;
 + dev-buf_count = 0;
 +
 + if (mutex_lock_interruptible(dev-v4l2_lock))
 + return -ERESTARTSYS;
 +
 + v4l2_device_call_all(dev-v4l2_dev, 0, video, s_stream, 1);
 +
 + /* The saa 7115 driver sets these wrong,
 +  * this leads to sync issues.
 +  * V_GATE1_START
 +  * V_GATE1_STOP
 +  * V_GATE1_MSB
 +  * All these should be 0x00 for this device.
 +  */
 + smi2021_write_reg(dev, 0x4a, 0x15, 0x00);
 + smi2021_write_reg(dev, 0x4a, 0x16, 0x00);
 + smi2021_write_reg(dev, 0x4a, 0x17, 0x00);
 +
 + rc = usb_control_msg(dev-udev, usb_sndctrlpipe(dev-udev, 0x00),
 + 0x01, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 + 0x01, 0x00, data, sizeof(data), 1000);
 + if (rc  0) {
 + smi2021_err(Could not start device!\n);
 + goto out_unlock;
 + }
 +
 + /* It's mandatory to set alt interface before allocating isoc buffer */
 + usb_set_interface(dev-udev, 0, 2);
 +
 + smi2021_write_reg(dev, 0, 0x1740, 0x1d);
 +
 + if (!dev-isoc_ctl.num_bufs) {
 + rc = smi2021_alloc_isoc(dev);
 + if (rc  0)
 + goto out_stop_hw;
 + }
 +
 + /* submit urbs and enable IRQ */
 + for (i = 0; i  dev-isoc_ctl.num_bufs; i++) {
 + rc = usb_submit_urb(dev-isoc_ctl.urb[i], 

Re: [RFC V1 5/8] smi2021: Add smi2021_video.c

2013-03-18 Thread Hans Verkuil
On Thu March 14 2013 15:07:01 Jon Arne Jørgensen wrote:
 This file is responsible for all communication with the video hardware
 and also starting and stopping the capture.
 
 It also contains the setup and handling of the usb ISOCHRONOUS transfers.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_video.c | 543 
 ++
  1 file changed, 543 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_video.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_video.c 
 b/drivers/media/usb/smi2021/smi2021_video.c
 new file mode 100644
 index 000..48f3e80
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_video.c
 @@ -0,0 +1,543 @@
 +/***
 + * smi2021_video.c   
   *
 + *   
   *
 + * USB Driver for SMI2021 - EasyCAP  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021x
 + * http://code.google.com/p/easycap-somagic-linux/
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com
 + *
 + */
 +
 +#include smi2021.h
 +
 +static void print_usb_err(struct smi2021_dev *dev, int packet, int status)
 +{
 + char *errmsg;
 +
 + switch (status) {
 + case -ENOENT:
 + errmsg = unlinked synchronuously;
 + break;
 + case -ECONNRESET:
 + errmsg = unlinked asynchronuously;
 + break;
 + case -ENOSR:
 + errmsg = Buffer error (overrun);
 + break;
 + case -EPIPE:
 + errmsg = Stalled (device not responding);
 + break;
 + case -EOVERFLOW:
 + errmsg = Babble (bad cable?);
 + break;
 + case -EPROTO:
 + errmsg = Bit-stuff error (bad cable?);
 + break;
 + case -EILSEQ:
 + errmsg = CRC/Timeout (could be anything);
 + break;
 + case -ETIME:
 + errmsg = Device does not respond;
 + break;
 + default:
 + errmsg = Unknown;
 + }
 +
 + if (packet  0) {
 + printk_ratelimited(KERN_WARNING Urb status %d [%s]\n,
 + status, errmsg);
 + } else {
 + printk_ratelimited(KERN_INFO URB packet %d, status %d [%s]\n,
 + packet, status, errmsg);
 + }
 +}
 +
 +static struct smi2021_buffer *smi2021_next_buffer(struct smi2021_dev *dev)
 +{
 + struct smi2021_buffer *buf = NULL;
 + unsigned long flags = 0;
 +
 + BUG_ON(dev-isoc_ctl.buf);
 +
 + spin_lock_irqsave(dev-buf_lock, flags);
 + if (!list_empty(dev-avail_bufs)) {
 + buf = list_first_entry(dev-avail_bufs, struct smi2021_buffer,
 + list);
 + list_del(buf-list);
 + }
 + spin_unlock_irqrestore(dev-buf_lock, flags);
 +
 + return buf;
 +}
 +
 +static void smi2021_buffer_done(struct smi2021_dev *dev)
 +{
 + struct smi2021_buffer *buf = dev-isoc_ctl.buf;
 +
 + dev-buf_count++;
 +
 + buf-vb.v4l2_buf.sequence = dev-buf_count  1;
 + buf-vb.v4l2_buf.field = V4L2_FIELD_INTERLACED;
 + buf-vb.v4l2_buf.bytesused = buf-pos;
 + do_gettimeofday(buf-vb.v4l2_buf.timestamp);
 +
 + vb2_set_plane_payload(buf-vb, 0, buf-pos);
 + vb2_buffer_done(buf-vb, VB2_BUF_STATE_DONE);
 +
 + dev-isoc_ctl.buf = NULL;
 +}
 +
 +static void copy_video(struct smi2021_dev *dev, u8 p)
 +{
 + struct smi2021_buffer *buf = dev-isoc_ctl.buf;
 +
 + int lines_per_field = dev-height / 2;
 + int line = 0;
 + int pos_in_line = 0;
 + unsigned int offset = 0;
 + 

Re: [RFC V1 4/8] smi2021: Add smi2021_v4l2.c

2013-03-18 Thread Hans Verkuil
On Thu March 14 2013 15:07:00 Jon Arne Jørgensen wrote:
 This file is responsible for registering the device with the v4l2 subsystem,
 and the communication with v4l2.
 Most of the v4l2 ioctls are just passed on to vidbuf2.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_v4l2.c | 566 
 +++
  1 file changed, 566 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_v4l2.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_v4l2.c 
 b/drivers/media/usb/smi2021/smi2021_v4l2.c
 new file mode 100644
 index 000..d402093
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_v4l2.c
 @@ -0,0 +1,566 @@

...

 +int smi2021_vb2_setup(struct smi2021_dev *dev)
 +{
 + int rc;
 + struct vb2_queue *q;
 +
 + q = dev-vb_vidq;
 + q-type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 + q-io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR;
 + q-drv_priv = dev;
 + q-buf_struct_size = sizeof(struct smi2021_buffer);
 + q-ops = smi2021_video_qops;
 + q-mem_ops = vb2_vmalloc_memops;

q-timestamp_type isn't filled in.

For that matter, neither the sequence number nor the timestamp are filled in
in v4l2_buffer during capturing.

You need to add a buf_finish op to fill those in (use v4l2_timestamp() for the
timestamp).

Regards,

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


Re: [RFC V1 2/8] smi2021: Add smi2021_main.c

2013-03-18 Thread Hans Verkuil
On Thu March 14 2013 15:06:58 Jon Arne Jørgensen wrote:
 This is the core of the smi2021 module.
 It will register the module with the kernel, and register the
 usb probe function.
 
 Signed-off-by: Jon Arne Jørgensen jona...@jonarne.no
 ---
  drivers/media/usb/smi2021/smi2021_main.c | 339 
 +++
  1 file changed, 339 insertions(+)
  create mode 100644 drivers/media/usb/smi2021/smi2021_main.c
 
 diff --git a/drivers/media/usb/smi2021/smi2021_main.c 
 b/drivers/media/usb/smi2021/smi2021_main.c
 new file mode 100644
 index 000..cc600e7
 --- /dev/null
 +++ b/drivers/media/usb/smi2021/smi2021_main.c
 @@ -0,0 +1,339 @@
 +/***
 + * smi2021_main.c
   *
 + *   
   *
 + * USB Driver for SMI2021 - EasyCAP  
   *
 + * USB ID 1c88:003c  
   *
 + *   
   *
 + * 
 *
 + *
 + * Copyright 2011-2013 Jon Arne Jørgensen
 + * jonjon.arnearne--a.t--gmail.com
 + *
 + * Copyright 2011, 2012 Tony Brown, Michal Demin, Jeffry Johnston
 + *
 + * This file is part of SMI2021
 + * http://code.google.com/p/easycap-somagic-linux/
 + *
 + * This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation, either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, see http://www.gnu.org/licenses/.
 + *
 + * This driver is heavily influensed by the STK1160 driver.
 + * Copyright (C) 2012 Ezequiel Garcia
 + * elezegarcia--a.t--gmail.com
 + *
 + */
 +
 +#include smi2021.h
 +
 +#define VENDOR_ID 0x1c88
 +
 +static unsigned int imput;
 +module_param(imput, int, 0644);
 +MODULE_PARM_DESC(input, Set default input);
 +
 +MODULE_LICENSE(GPL);
 +MODULE_AUTHOR(Jon Arne Jørgensen jonjon.arnearne--a.t--gmail.com);
 +MODULE_DESCRIPTION(SMI2021 - EasyCap);
 +MODULE_VERSION(SMI2021_DRIVER_VERSION);
 +
 +
 +struct usb_device_id smi2021_usb_device_id_table[] = {
 + { USB_DEVICE(VENDOR_ID, 0x003c) },
 + { USB_DEVICE(VENDOR_ID, 0x003d) },
 + { USB_DEVICE(VENDOR_ID, 0x003e) },
 + { USB_DEVICE(VENDOR_ID, 0x003f) },
 + { }
 +};
 +
 +MODULE_DEVICE_TABLE(usb, smi2021_usb_device_id_table);
 +
 +static unsigned short saa7113_addrs[] = {
 + 0x4a,
 + I2C_CLIENT_END
 +};
 +
 +/**/
 +/*   
  */
 +/*  Write to saa7113 
  */
 +/*   
  */
 +/**/
 +
 +inline int transfer_usb_ctrl(struct smi2021_dev *dev, u8 *data, int len)
 +{
 + return usb_control_msg(dev-udev, usb_sndctrlpipe(dev-udev, 0x00),
 + 0x01, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 + 0x0b, 0x00,
 + data, len, 1000);
 +}
 +
 +int smi2021_write_reg(struct smi2021_dev *dev, u8 addr, u16 reg, u8 val)
 +{
 + int rc;
 + u8 snd_data[8];
 +
 + memset(snd_data, 0x00, 8);
 +
 + snd_data[SMI2021_CTRL_HEAD] = 0x0b;
 + snd_data[SMI2021_CTRL_ADDR] = addr;
 + snd_data[SMI2021_CTRL_DATA_SIZE] = 0x01;
 +
 + if (addr) {
 + /* This is I2C data for the saa7113 chip */
 + snd_data[SMI2021_CTRL_BM_DATA_TYPE] = 0xc0;
 + snd_data[SMI2021_CTRL_BM_DATA_OFFSET] = 0x01;
 +
 + snd_data[SMI2021_CTRL_I2C_REG] = reg;
 + snd_data[SMI2021_CTRL_I2C_VAL] = val;
 + } else {
 + /* This is register settings for the smi2021 chip */
 + snd_data[SMI2021_CTRL_BM_DATA_OFFSET] = 0x82;
 +
 + snd_data[SMI2021_CTRL_REG_HI] = __cpu_to_be16(reg)  8;
 + snd_data[SMI2021_CTRL_REG_LO] = __cpu_to_be16(reg);
 +
 + }
 +

Don't transfer memory from the stack. It always has to be k[mz]alloced memory.

 + rc = transfer_usb_ctrl(dev, snd_data, 8);
 + if (rc  0) {
 + smi2021_warn(write failed on register 0x%x, errno: %d\n,
 + reg, rc);
 + return rc;
 + }
 +
 +

Re: [PATCH v3] media: davinci: kconfig: fix incorrect selects

2013-03-18 Thread Sekhar Nori
On 3/16/2013 2:06 PM, Prabhakar Lad wrote:
 Hi Sekhar,
 
 Thanks for the patch!
 
 On Tue, Mar 12, 2013 at 2:44 PM, Sekhar Nori nsek...@ti.com wrote:
 drivers/media/platform/davinci/Kconfig uses selects where
 it should be using 'depends on'. This results in warnings of
 the following sort when doing randconfig builds.

 warning: (VIDEO_DM6446_CCDC  VIDEO_DM355_CCDC  VIDEO_ISIF  
 VIDEO_DAVINCI_VPBE_DISPLAY) selects VIDEO_VPSS_SYSTEM which has unmet direct 
 dependencies (MEDIA_SUPPORT  V4L_PLATFORM_DRIVERS  ARCH_DAVINCI)

 The VPIF kconfigs had a strange 'select' and 'depends on' cross
 linkage which have been fixed as well by removing unneeded
 VIDEO_DAVINCI_VPIF config symbol.

 Similarly, remove the unnecessary VIDEO_VPSS_SYSTEM and
 VIDEO_VPFE_CAPTURE. They don't select any independent functionality
 and were being used to manage code dependencies which can
 be handled using makefile.

 Selecting video modules is now dependent on all ARCH_DAVINCI
 instead of specific EVMs and SoCs earlier. This should help build
 coverage. Remove unnecessary 'default y' for some config symbols.

 While at it, fix the Kconfig help text to make it more readable
 and fix names of modules created during module build.

 Rename VIDEO_ISIF to VIDEO_DM365_ISIF as per suggestion from
 Prabhakar.

 This patch has only been build tested; I have tried to not break
 any existing assumptions. I do not have the setup to test video,
 so any test reports welcome.

 The series which I posted yesterday [1] for DM365 VPBE, uses a exported
 symbol 'vpss_enable_clock' so If I build vpbe as module it complains
 for following,
 
 arch/arm/mach-davinci/built-in.o: In function `dm365_venc_setup_clock':
 pm_domain.c:(.text+0x302c): undefined reference to `vpss_enable_clock'
 pm_domain.c:(.text+0x3038): undefined reference to `vpss_enable_clock'
 pm_domain.c:(.text+0x3060): undefined reference to `vpss_enable_clock'
 pm_domain.c:(.text+0x306c): undefined reference to `vpss_enable_clock'
 
 So how would you suggest to handle this VPSS config ?
 
 [1] 
 http://www.mail-archive.com/davinci-linux-open-source@linux.davincidsp.com/msg25443.html

I replied on the above thread. Lets continue the discussion there since
this error is not really related to this patch.

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


Re: [RFC V1 5/8] smi2021: Add smi2021_video.c

2013-03-18 Thread Bjørn Mork
Hans Verkuil hverk...@xs4all.nl writes:

 +/*
 + *
 + * The device delivers data in chunks of 0x400 bytes.
 + * The four first bytes is a magic header to identify the chunks.
 + *  0xaa 0xaa 0x00 0x00 = saa7113 Active Video Data
 + *  0xaa 0xaa 0x00 0x01 = PCM - 24Bit 2 Channel audio data
 + */
 +static void process_packet(struct smi2021_dev *dev, u8 *p, int len)
 +{
 +int i;
 +u32 *header;
 +
 +if (len % 0x400 != 0) {
 +printk_ratelimited(KERN_INFO smi2021::%s: len: %d\n,
 +__func__, len);
 +return;
 +}
 +
 +for (i = 0; i  len; i += 0x400) {
 +header = (u32 *)(p + i);
 +switch (__cpu_to_be32(*header)) {

 That's not right. You probably mean __be32_to_cpu, that makes more sense.

 +case 0x: {
 +parse_video(dev, p+i+4, 0x400-4);
 +break;
 +}
 +case 0x0001: {
 +smi2021_audio(dev, p+i+4, 0x400-4);
 +break;
 +}

This could be just me, but I would have done it like this to take
advantage of compile time constant conversions (and also dropping the
noisy extra {}s):

switch (*header) {
case cpu_to_be32(0x):
parse_video(dev, p+i+4, 0x400-4);
break;
case cpu_to_be32(0x0001):
smi2021_audio(dev, p+i+4, 0x400-4);
break;
..


From the name of the function I assume the difference may actually be
measurable here if this runs for every processed packet.


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


Re: [RFC V1 7/8] smi2021: Add smi2021_bl.c

2013-03-18 Thread Bjørn Mork
Jon Arne Jørgensen jona...@jonarne.no writes:

 This is the smi2021-bootloader module.
 This module will upload the firmware for the different somagic devices.

I really don't understand why you want to make that a separate module.
Building both the bootlader driver and the real driver into the same
module will make sure that either both or none are available, document
the relationship to the end user, and allow you to tell the user that
firmware files may be needed for the real driver by using the
MODULE_FIRMWARE macro (which you should do, IMHO).

 +static unsigned int firmware_version;
 +module_param(firmware_version, int, 0644);
 +MODULE_PARM_DESC(firmware_version,
 + Firmware version to be uploaded to device\n
 + if there are more than one firmware present);
 +
 +struct usb_device_id smi2021_bootloader_id_table[] = {
 + { USB_DEVICE(0x1c88, 0x0007) },
 + { }
 +};
 +
 +struct smi2021_firmware {
 + int id;
 + const char  *name;
 + int found;
 +};
 +
 +struct smi2021_firmware available_fw[] = {
 + {
 + .id = 0x3c,
 + .name = smi2021_3c.bin,
 + },
 + {
 + .id = 0x3e,
 + .name = smi2021_3e.bin,
 + },
 + {
 + .id = 0x3f,
 + .name = smi2021_3f.bin,
 + }
 +};


How does the user know which firmware to select?  Will any of them work,
or are they device specific? Either way I believe you should publish all
three names using MODULE_FIRMWARE.


 +static int smi2021_load_firmware(struct usb_device *udev,
 + const struct firmware *firmware)
 +{
 + int i, size, rc = 0;
 + u8 *chunk;
 + u16 ack = 0x;
 +
 + if (udev == NULL)
 + goto end_out;

Is this possible? 



 + size = FIRMWARE_CHUNK_SIZE + FIRMWARE_HEADER_SIZE;
 + chunk = kzalloc(size, GFP_KERNEL);
 + chunk[0] = 0x05;
 + chunk[1] = 0xff;
 +
 + if (chunk == NULL) {

This on the other hand, will happen.  But you have already oopsed when
you test it here...


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


[PATCH] [media] mx2_camera: use module_platform_driver_probe()

2013-03-18 Thread Fabio Porcedda
The commit 39793c6 [media] mx2_camera: Convert it to platform driver
used module_platform_driver() to make code smaller,
but since the driver used platform_driver_probe is more appropriate
to use module_platform_driver_probe().

Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
Cc: Fabio Estevam fabio.este...@freescale.com
Cc: Guennadi Liakhovetski g.liakhovet...@gmx.de
Cc: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/platform/soc_camera/mx2_camera.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/soc_camera/mx2_camera.c 
b/drivers/media/platform/soc_camera/mx2_camera.c
index ffba7d9..848dff9 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -1619,10 +1619,9 @@ static struct platform_driver mx2_camera_driver = {
},
.id_table   = mx2_camera_devtype,
.remove = mx2_camera_remove,
-   .probe  = mx2_camera_probe,
 };
 
-module_platform_driver(mx2_camera_driver);
+module_platform_driver_probe(mx2_camera_driver, mx2_camera_probe);
 
 MODULE_DESCRIPTION(i.MX27 SoC Camera Host driver);
 MODULE_AUTHOR(Sascha Hauer s...@pengutronix.de);
-- 
1.8.2

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


Re: [PATCH 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-18 Thread Fabio Porcedda
On Fri, Mar 15, 2013 at 9:18 PM, Arnd Bergmann a...@arndb.de wrote:
 On Friday 15 March 2013, H Hartley Sweeten wrote:
 Arnd,

 Ill look at converting the ep93xx pwm driver to the PWM subsystem. The only 
 issue is
 the current driver exposes a sysfs interface that I think is not available 
 in that subsystem.

 You can probably keep providing that interface if you have active users.

 * Regarding the use of module_platform_driver_probe, I'm a little worried 
 about
   the interactions with deferred probing. I don't think there are any 
  regressions,
   but we should probably make people aware that one cannot return 
  -EPROBE_DEFER
   from a platform_driver_probe function.

 The ep93xx pwm driver does not need to use platform_driver_probe(). It can 
 be changed
 to use module_platform_driver() by just moving the .probe to the 
 platform_driver. This
 driver was added before module_platform_driver() was available and I used the
 platform_driver_probe() thinking it would save a couple lines of code.

Since by using platform_driver_probe() the  function
ep93xx_pwm_probe() is freed after initialization,
is better to use module_platform_drive_probe().
IMHO i don't see any good reason to use module_platform_driver() for
this driver.

Best regards
Fabio Porcedda

 I'll change this in a bit. Right now I'm trying to work out why kernel 3.8 
 is not booting
 on the ep93xx. I had 3.6.6 on my development board and 3.7 works fine but 
 3.8 hangs
 without uncompressing the kernel.

 Ok, thanks!

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


Re: [PATCH v6 3/7] media: soc-camera: switch I2C subdevice drivers to use v4l2-clk

2013-03-18 Thread Guennadi Liakhovetski
On Mon, 18 Mar 2013, Hans Verkuil wrote:

 On Fri March 15 2013 22:27:49 Guennadi Liakhovetski wrote:
  Instead of centrally enabling and disabling subdevice master clocks in
  soc-camera core, let subdevice drivers do that themselves, using the
  V4L2 clock API and soc-camera convenience wrappers.
  
  Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
  ---
  
  v6: clock name update
  
   drivers/media/i2c/soc_camera/imx074.c  |   18 ++-
   drivers/media/i2c/soc_camera/mt9m001.c |   17 ++-
   drivers/media/i2c/soc_camera/mt9m111.c |   20 ++-
   drivers/media/i2c/soc_camera/mt9t031.c |   19 ++-
   drivers/media/i2c/soc_camera/mt9t112.c |   19 ++-
   drivers/media/i2c/soc_camera/mt9v022.c |   17 ++-
   drivers/media/i2c/soc_camera/ov2640.c  |   19 ++-
   drivers/media/i2c/soc_camera/ov5642.c  |   20 ++-
   drivers/media/i2c/soc_camera/ov6650.c  |   17 ++-
   drivers/media/i2c/soc_camera/ov772x.c  |   15 ++-
   drivers/media/i2c/soc_camera/ov9640.c  |   17 ++-
   drivers/media/i2c/soc_camera/ov9640.h  |1 +
   drivers/media/i2c/soc_camera/ov9740.c  |   18 ++-
   drivers/media/i2c/soc_camera/rj54n1cb0c.c  |   17 ++-
   drivers/media/i2c/soc_camera/tw9910.c  |   18 ++-
   drivers/media/platform/soc_camera/soc_camera.c |  172 
  +++-
   .../platform/soc_camera/soc_camera_platform.c  |2 +-
   include/media/soc_camera.h |   13 +-
   18 files changed, 355 insertions(+), 84 deletions(-)
  
  diff --git a/drivers/media/i2c/soc_camera/imx074.c 
  b/drivers/media/i2c/soc_camera/imx074.c
  index a2a5cbb..cee5345 100644
  --- a/drivers/media/i2c/soc_camera/imx074.c
  +++ b/drivers/media/i2c/soc_camera/imx074.c
  @@ -18,6 +18,7 @@
   #include linux/module.h
   
   #include media/soc_camera.h
  +#include media/v4l2-clk.h
   #include media/v4l2-subdev.h
   #include media/v4l2-chip-ident.h
   
  @@ -77,6 +78,7 @@ struct imx074_datafmt {
   struct imx074 {
  struct v4l2_subdev  subdev;
  const struct imx074_datafmt *fmt;
  +   struct v4l2_clk *clk;
   };
   
   static const struct imx074_datafmt imx074_colour_fmts[] = {
  @@ -272,8 +274,9 @@ static int imx074_s_power(struct v4l2_subdev *sd, int 
  on)
   {
  struct i2c_client *client = v4l2_get_subdevdata(sd);
  struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
  +   struct imx074 *priv = to_imx074(client);
   
  -   return soc_camera_set_power(client-dev, ssdd, on);
  +   return soc_camera_set_power(client-dev, ssdd, priv-clk, on);
   }
   
   static int imx074_g_mbus_config(struct v4l2_subdev *sd,
  @@ -431,6 +434,7 @@ static int imx074_probe(struct i2c_client *client,
  struct imx074 *priv;
  struct i2c_adapter *adapter = to_i2c_adapter(client-dev.parent);
  struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
  +   int ret;
   
  if (!ssdd) {
  dev_err(client-dev, IMX074: missing platform data!\n);
  @@ -451,13 +455,23 @@ static int imx074_probe(struct i2c_client *client,
   
  priv-fmt   = imx074_colour_fmts[0];
   
  -   return imx074_video_probe(client);
  +   priv-clk = v4l2_clk_get(priv-subdev, mclk);
  +   if (IS_ERR(priv-clk))
  +   return PTR_ERR(priv-clk);
  +
  +   ret = imx074_video_probe(client);
  +   if (ret  0)
  +   v4l2_clk_put(priv-clk);
  +
 
 I feel uneasy about this. It's not the clock part as such but the fact that
 assumptions are made about the usage of this sensor driver. It basically
 comes down to the fact that these drivers are *still* tied to the soc-camera
 framework. I think I am going to work on this in a few weeks time to cut
 these drivers loose from soc-camera. We discussed how to do that in the past.

Sorry, not sure I understand. This is a generic (V4L2) clock, it has 
nothing specific to soc-camera.

 The whole point of the subdev API is to make drivers independent of bridge
 drivers, and these soc-camera subdev drivers are the big exception and they
 stick out like a sore thumb.

We are moving towards complete driver independency from the soc-camera 
framework, and, afaics, there's not much left. Simply noone is interested 
enough to do the work or to pay for it, noone has a really burning 
use-case. And without one it's not very easy to implement things with no 
test case. But sure, you're most welcome to work on this :)

 Anyway, w.r.t. the clock use: what happens if these drivers are used in e.g.
 a USB webcam driver? In that case there probably won't be a clock involved
 (well, there is one, but that is likely to be setup by the firmware/hardware
 itself).

Well, from the sensor driver PoV if the sensor needs a clock it seems 
logical for the driver to request it and to fail if it's not available. 
USB cameras could provide a dummy clock, or we could 

Re: [PATCH] [media] mx2_camera: use module_platform_driver_probe()

2013-03-18 Thread Guennadi Liakhovetski
Hi Fabio

On Mon, 18 Mar 2013, Fabio Porcedda wrote:

 The commit 39793c6 [media] mx2_camera: Convert it to platform driver
 used module_platform_driver() to make code smaller,
 but since the driver used platform_driver_probe is more appropriate
 to use module_platform_driver_probe().
 
 Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com
 Cc: Fabio Estevam fabio.este...@freescale.com
 Cc: Guennadi Liakhovetski g.liakhovet...@gmx.de
 Cc: Mauro Carvalho Chehab mche...@redhat.com

Thanks, will queue for 3.10.

Guennadi

 ---
  drivers/media/platform/soc_camera/mx2_camera.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
 
 diff --git a/drivers/media/platform/soc_camera/mx2_camera.c 
 b/drivers/media/platform/soc_camera/mx2_camera.c
 index ffba7d9..848dff9 100644
 --- a/drivers/media/platform/soc_camera/mx2_camera.c
 +++ b/drivers/media/platform/soc_camera/mx2_camera.c
 @@ -1619,10 +1619,9 @@ static struct platform_driver mx2_camera_driver = {
   },
   .id_table   = mx2_camera_devtype,
   .remove = mx2_camera_remove,
 - .probe  = mx2_camera_probe,
  };
  
 -module_platform_driver(mx2_camera_driver);
 +module_platform_driver_probe(mx2_camera_driver, mx2_camera_probe);
  
  MODULE_DESCRIPTION(i.MX27 SoC Camera Host driver);
  MODULE_AUTHOR(Sascha Hauer s...@pengutronix.de);
 -- 
 1.8.2
 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 3/7] media: soc-camera: switch I2C subdevice drivers to use v4l2-clk

2013-03-18 Thread Hans Verkuil
On Mon March 18 2013 11:08:16 Guennadi Liakhovetski wrote:
 On Mon, 18 Mar 2013, Hans Verkuil wrote:
 
  On Fri March 15 2013 22:27:49 Guennadi Liakhovetski wrote:
   Instead of centrally enabling and disabling subdevice master clocks in
   soc-camera core, let subdevice drivers do that themselves, using the
   V4L2 clock API and soc-camera convenience wrappers.
   
   Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
   ---
   
   v6: clock name update
   
drivers/media/i2c/soc_camera/imx074.c  |   18 ++-
drivers/media/i2c/soc_camera/mt9m001.c |   17 ++-
drivers/media/i2c/soc_camera/mt9m111.c |   20 ++-
drivers/media/i2c/soc_camera/mt9t031.c |   19 ++-
drivers/media/i2c/soc_camera/mt9t112.c |   19 ++-
drivers/media/i2c/soc_camera/mt9v022.c |   17 ++-
drivers/media/i2c/soc_camera/ov2640.c  |   19 ++-
drivers/media/i2c/soc_camera/ov5642.c  |   20 ++-
drivers/media/i2c/soc_camera/ov6650.c  |   17 ++-
drivers/media/i2c/soc_camera/ov772x.c  |   15 ++-
drivers/media/i2c/soc_camera/ov9640.c  |   17 ++-
drivers/media/i2c/soc_camera/ov9640.h  |1 +
drivers/media/i2c/soc_camera/ov9740.c  |   18 ++-
drivers/media/i2c/soc_camera/rj54n1cb0c.c  |   17 ++-
drivers/media/i2c/soc_camera/tw9910.c  |   18 ++-
drivers/media/platform/soc_camera/soc_camera.c |  172 
   +++-
.../platform/soc_camera/soc_camera_platform.c  |2 +-
include/media/soc_camera.h |   13 +-
18 files changed, 355 insertions(+), 84 deletions(-)
   
   diff --git a/drivers/media/i2c/soc_camera/imx074.c 
   b/drivers/media/i2c/soc_camera/imx074.c
   index a2a5cbb..cee5345 100644
   --- a/drivers/media/i2c/soc_camera/imx074.c
   +++ b/drivers/media/i2c/soc_camera/imx074.c
   @@ -18,6 +18,7 @@
#include linux/module.h

#include media/soc_camera.h
   +#include media/v4l2-clk.h
#include media/v4l2-subdev.h
#include media/v4l2-chip-ident.h

   @@ -77,6 +78,7 @@ struct imx074_datafmt {
struct imx074 {
 struct v4l2_subdev  subdev;
 const struct imx074_datafmt *fmt;
   + struct v4l2_clk *clk;
};

static const struct imx074_datafmt imx074_colour_fmts[] = {
   @@ -272,8 +274,9 @@ static int imx074_s_power(struct v4l2_subdev *sd, int 
   on)
{
 struct i2c_client *client = v4l2_get_subdevdata(sd);
 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
   + struct imx074 *priv = to_imx074(client);

   - return soc_camera_set_power(client-dev, ssdd, on);
   + return soc_camera_set_power(client-dev, ssdd, priv-clk, on);
}

static int imx074_g_mbus_config(struct v4l2_subdev *sd,
   @@ -431,6 +434,7 @@ static int imx074_probe(struct i2c_client *client,
 struct imx074 *priv;
 struct i2c_adapter *adapter = to_i2c_adapter(client-dev.parent);
 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
   + int ret;

 if (!ssdd) {
 dev_err(client-dev, IMX074: missing platform data!\n);
   @@ -451,13 +455,23 @@ static int imx074_probe(struct i2c_client *client,

 priv-fmt   = imx074_colour_fmts[0];

   - return imx074_video_probe(client);
   + priv-clk = v4l2_clk_get(priv-subdev, mclk);
   + if (IS_ERR(priv-clk))
   + return PTR_ERR(priv-clk);
   +
   + ret = imx074_video_probe(client);
   + if (ret  0)
   + v4l2_clk_put(priv-clk);
   +
  
  I feel uneasy about this. It's not the clock part as such but the fact that
  assumptions are made about the usage of this sensor driver. It basically
  comes down to the fact that these drivers are *still* tied to the soc-camera
  framework. I think I am going to work on this in a few weeks time to cut
  these drivers loose from soc-camera. We discussed how to do that in the 
  past.
 
 Sorry, not sure I understand. This is a generic (V4L2) clock, it has 
 nothing specific to soc-camera.

The assumption that there is a clock that needs to be set up is soc_camera
specific IMHO.

  The whole point of the subdev API is to make drivers independent of bridge
  drivers, and these soc-camera subdev drivers are the big exception and they
  stick out like a sore thumb.
 
 We are moving towards complete driver independency from the soc-camera 
 framework, and, afaics, there's not much left. Simply noone is interested 
 enough to do the work or to pay for it, noone has a really burning 
 use-case. And without one it's not very easy to implement things with no 
 test case. But sure, you're most welcome to work on this :)

I'll see what I can do since I am interested in doing this :-)

  Anyway, w.r.t. the clock use: what happens if these drivers are used in e.g.
  a USB webcam driver? In that case there probably won't be a clock involved
  (well, 

Re: [PATCH 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-18 Thread Arnd Bergmann
On Monday 18 March 2013, Fabio Porcedda wrote:
 Since by using platform_driver_probe() the  function
 ep93xx_pwm_probe() is freed after initialization,
 is better to use module_platform_drive_probe().
 IMHO i don't see any good reason to use module_platform_driver() for
 this driver.

As I commented earlier, the platform_driver_probe() and
module_platform_drive_probe() interfaces are rather dangerous in combination
with deferred probing, I would much prefer Harley's patch.

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


Re: [PATCH 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-18 Thread Fabio Porcedda
On Mon, Mar 18, 2013 at 11:58 AM, Arnd Bergmann a...@arndb.de wrote:
 On Monday 18 March 2013, Fabio Porcedda wrote:
 Since by using platform_driver_probe() the  function
 ep93xx_pwm_probe() is freed after initialization,
 is better to use module_platform_drive_probe().
 IMHO i don't see any good reason to use module_platform_driver() for
 this driver.

 As I commented earlier, the platform_driver_probe() and
 module_platform_drive_probe() interfaces are rather dangerous in combination
 with deferred probing, I would much prefer Harley's patch.

Since those drivers don't use -EPROBE_DEFER i was thinking that they don't use
deferred probing.
I'm missing something?

Best regards
Fabio Porcedda

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


Re: [PATCH 10/10] drivers: misc: use module_platform_driver_probe()

2013-03-18 Thread Arnd Bergmann
On Monday 18 March 2013, Fabio Porcedda wrote:
 
 On Mon, Mar 18, 2013 at 11:58 AM, Arnd Bergmann a...@arndb.de wrote:
  On Monday 18 March 2013, Fabio Porcedda wrote:
  Since by using platform_driver_probe() the  function
  ep93xx_pwm_probe() is freed after initialization,
  is better to use module_platform_drive_probe().
  IMHO i don't see any good reason to use module_platform_driver() for
  this driver.
 
  As I commented earlier, the platform_driver_probe() and
  module_platform_drive_probe() interfaces are rather dangerous in combination
  with deferred probing, I would much prefer Harley's patch.
 
 Since those drivers don't use -EPROBE_DEFER i was thinking that they don't use
 deferred probing.
 I'm missing something?

clk_get() may return -EPROBE_DEFER after ep93xx is converted to use the
common clk API. We currently return the value of clk_get from the probe()
function, which will automatically do the right thing as long as the probe
function remains reachable.

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


[PATCH v2] soc_camera: Add RGB666 RGB888 formats

2013-03-18 Thread Phil Edworthy
Based on work done by Katsuya Matsubara.

Signed-off-by: Phil Edworthy phil.edwor...@renesas.com
---
v2:
 - Added documentation.
 - Added SOCAM_DATAWIDTH_12 definition.

 Documentation/DocBook/media/v4l/subdev-formats.xml |  206 +++-
 Documentation/DocBook/media_api.tmpl   |1 +
 drivers/media/platform/soc_camera/soc_mediabus.c   |   42 
 include/media/soc_camera.h |7 +-
 include/media/soc_mediabus.h   |3 +
 include/uapi/linux/v4l2-mediabus.h |6 +-
 6 files changed, 253 insertions(+), 12 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index cc51372..adc6198 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -93,19 +93,35 @@
 
   table pgwide=0 frame=none id=v4l2-mbus-pixelcode-rgb
titleRGB formats/title
-   tgroup cols=11
+   tgroup cols=27
  colspec colname=id align=left /
  colspec colname=code align=center/
  colspec colname=bit /
- colspec colnum=4 colname=b07 align=center /
- colspec colnum=5 colname=b06 align=center /
- colspec colnum=6 colname=b05 align=center /
- colspec colnum=7 colname=b04 align=center /
- colspec colnum=8 colname=b03 align=center /
- colspec colnum=9 colname=b02 align=center /
- colspec colnum=10 colname=b01 align=center /
- colspec colnum=11 colname=b00 align=center /
- spanspec namest=b07 nameend=b00 spanname=b0 /
+ colspec colnum=4 colname=b23 align=center /
+ colspec colnum=5 colname=b22 align=center /
+ colspec colnum=6 colname=b21 align=center /
+ colspec colnum=7 colname=b20 align=center /
+ colspec colnum=8 colname=b19 align=center /
+ colspec colnum=9 colname=b18 align=center /
+ colspec colnum=10 colname=b17 align=center /
+ colspec colnum=11 colname=b16 align=center /
+ colspec colnum=12 colname=b15 align=center /
+ colspec colnum=13 colname=b14 align=center /
+ colspec colnum=14 colname=b13 align=center /
+ colspec colnum=15 colname=b12 align=center /
+ colspec colnum=16 colname=b11 align=center /
+ colspec colnum=17 colname=b10 align=center /
+ colspec colnum=18 colname=b09 align=center /
+ colspec colnum=19 colname=b08 align=center /
+ colspec colnum=20 colname=b07 align=center /
+ colspec colnum=21 colname=b06 align=center /
+ colspec colnum=22 colname=b05 align=center /
+ colspec colnum=23 colname=b04 align=center /
+ colspec colnum=24 colname=b03 align=center /
+ colspec colnum=25 colname=b02 align=center /
+ colspec colnum=26 colname=b01 align=center /
+ colspec colnum=27 colname=b00 align=center /
+ spanspec namest=b23 nameend=b00 spanname=b0 /
  thead
row
  entryIdentifier/entry
@@ -117,6 +133,22 @@
  entry/entry
  entry/entry
  entryBit/entry
+ entry23/entry
+ entry22/entry
+ entry21/entry
+ entry20/entry
+ entry19/entry
+ entry18/entry
+ entry17/entry
+ entry16/entry
+ entry15/entry
+ entry14/entry
+ entry13/entry
+ entry12/entry
+ entry11/entry
+ entry10/entry
+ entry9/entry
+ entry8/entry
  entry7/entry
  entry6/entry
  entry5/entry
@@ -132,6 +164,7 @@
  entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_BE/entry
  entry0x1001/entry
  entry/entry
+ dash-ent-16;
  entry0/entry
  entry0/entry
  entry0/entry
@@ -145,6 +178,7 @@
  entry/entry
  entry/entry
  entry/entry
+ dash-ent-16;
  entrygsubscript3/subscript/entry
  entrygsubscript2/subscript/entry
  entrygsubscript1/subscript/entry
@@ -158,6 +192,7 @@
  entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_LE/entry
  entry0x1002/entry
  entry/entry
+ dash-ent-16;
  entrygsubscript3/subscript/entry
  entrygsubscript2/subscript/entry
  entrygsubscript1/subscript/entry
@@ -171,6 +206,7 @@
  entry/entry
  entry/entry
  entry/entry
+ dash-ent-16;
  entry0/entry
  entry0/entry
  entry0/entry
@@ -184,6 +220,7 @@
  entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/entry
  entry0x1003/entry
  entry/entry
+ dash-ent-16;
  entry0/entry
  entryrsubscript4/subscript/entry
  

[REVIEW PATCH 00/19] solo6x10: driver overhaul

2013-03-18 Thread Hans Verkuil
Hi all,

This is my second attempt. This time I sync to the latest code from Bluecherry
first before applying my patches.

Remaining open issues:

1) Most importantly, the video from video0 is broken: it is supposed to be
   either one of the four inputs or a 2x2 image of all four inputs, instead I
   always get the first video line of the input repeated for the whole image.

   I have no idea why and it would be very nice if someone from Bluecherry
   can look at this. I do not see anything wrong in the DMA code, so it is
   a mystery to me.

2) I couldn't get it to work on a big-endian system. Perhaps it is because
   the PCI card is sitting in a PCIe slot using a PCIe-to-PCI adapter.

3) The 'extended streams' have been disabled. Basically you can get two
   encoded streams out of the box: each with different encoder settings
   (e.g. high and low bitrates). This should probably be implemented as
   an extra video node.

4) There is a custom extension for motion detection. Besides adding two
   private ioctls to support regional motion thresholds I left that part
   otherwise unchanged as it doesn't look too bad, but I am unable to test
   it properly. I've ordered a suitable CCTV camera from dealextreme, but that
   will take a few weeks before I have it (dx.com is cheap, but delivery is
   quite slow). I'd like to experiment a bit with this.

5) The tw28* 'drivers' should really be split off as subdevice drivers.

6) Capture of video0 is now using dma-contig. It used to be dma-sg, but due
   to locking issues Bluecherry changed it to dma-contig. So I've kept it
   that way, but it can probably be converted back to dma-sg. But issue 1 should
   be fixed first before we mess with this.

So there is still work to be done, but at least the driver is in a much better
state.

If there are no more comments, then I'll add a final patch that prefixes the
sources with 'solo6x10-' and post a pull request on Friday.

The idea is that Bluecherry will develop from this code base and keep the
kernel driver in sync.

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


[REVIEW PATCH 02/19] solo6x10: fix querycap and update driver version.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Setup correct bus_info, let the v4l2 core set the version and add device_caps
support.

Also update the module version to 3.0.0 since this is a major upgrade.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/solo6x10.h |   11 +--
 drivers/staging/media/solo6x10/v4l2-enc.c |9 -
 drivers/staging/media/solo6x10/v4l2.c |9 -
 3 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index 44ae160..a8924a9 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -71,16 +71,7 @@
 
 #define SOLO_MAX_CHANNELS  16
 
-/* Make sure these two match */
-#define SOLO6X10_VER_MAJOR 2
-#define SOLO6X10_VER_MINOR 4
-#define SOLO6X10_VER_SUB   4
-#define SOLO6X10_VER_NUM \
-   KERNEL_VERSION(SOLO6X10_VER_MAJOR, SOLO6X10_VER_MINOR, SOLO6X10_VER_SUB)
-#define SOLO6X10_VERSION \
-   __stringify(SOLO6X10_VER_MAJOR) . \
-   __stringify(SOLO6X10_VER_MINOR) . \
-   __stringify(SOLO6X10_VER_SUB)
+#define SOLO6X10_VERSION   3.0.0
 
 /*
  * The SOLO6x10 actually has 8 i2c channels, but we only use 2.
diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index b05b328..8f02af2 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -991,12 +991,11 @@ static int solo_enc_querycap(struct file *file, void  
*priv,
strcpy(cap-driver, SOLO6X10_NAME);
snprintf(cap-card, sizeof(cap-card), Softlogic 6x10 Enc %d,
 solo_enc-ch);
-   snprintf(cap-bus_info, sizeof(cap-bus_info), PCI %s,
+   snprintf(cap-bus_info, sizeof(cap-bus_info), PCI:%s,
 pci_name(solo_dev-pdev));
-   cap-version = SOLO6X10_VER_NUM;
-   cap-capabilities = V4L2_CAP_VIDEO_CAPTURE |
-   V4L2_CAP_READWRITE |
-   V4L2_CAP_STREAMING;
+   cap-device_caps = V4L2_CAP_VIDEO_CAPTURE |
+   V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
+   cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
 }
 
diff --git a/drivers/staging/media/solo6x10/v4l2.c 
b/drivers/staging/media/solo6x10/v4l2.c
index f8ec2a3..d2f6eb6 100644
--- a/drivers/staging/media/solo6x10/v4l2.c
+++ b/drivers/staging/media/solo6x10/v4l2.c
@@ -476,12 +476,11 @@ static int solo_querycap(struct file *file, void  *priv,
 
strcpy(cap-driver, SOLO6X10_NAME);
strcpy(cap-card, Softlogic 6x10);
-   snprintf(cap-bus_info, sizeof(cap-bus_info), PCI %s,
+   snprintf(cap-bus_info, sizeof(cap-bus_info), PCI:%s,
 pci_name(solo_dev-pdev));
-   cap-version = SOLO6X10_VER_NUM;
-   cap-capabilities = V4L2_CAP_VIDEO_CAPTURE |
-   V4L2_CAP_READWRITE |
-   V4L2_CAP_STREAMING;
+   cap-device_caps = V4L2_CAP_VIDEO_CAPTURE |
+   V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
+   cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
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


[REVIEW PATCH 05/19] solo6x10: fix various format-related compliancy issues.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

- try_fmt should never return -EBUSY.
- invalid pix-field values were not mapped to a valid value.
- the priv field of struct v4l2_pix_format wasn't zeroed.
- the try_fmt error code was not checked in set_fmt.
- enum_framesizes/intervals is valid for both MJPEG and MPEG pixel formats.
- enum_frameintervals didn't check width and height and reported the
  wrong range.
- s_parm didn't set readbuffers.
- don't fail on invalid colorspace, just replace with the valid colorspace.
- bytesperline should be 0 for compressed formats.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/v4l2-enc.c |   51 -
 drivers/staging/media/solo6x10/v4l2.c |   30 +++--
 2 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index 1fbd95f..bf52a73 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -1039,13 +1039,6 @@ static int solo_enc_try_fmt_cap(struct file *file, void 
*priv,
pix-pixelformat != V4L2_PIX_FMT_MJPEG)
return -EINVAL;
 
-   /* We cannot change width/height in mid mpeg */
-   if (atomic_read(solo_enc-mpeg_readers)  0) {
-   if (pix-width != solo_enc-width ||
-   pix-height != solo_enc-height)
-   return -EBUSY;
-   }
-
if (pix-width  solo_dev-video_hsize ||
pix-height  solo_dev-video_vsize  1) {
/* Default to CIF 1/2 size */
@@ -1057,14 +1050,20 @@ static int solo_enc_try_fmt_cap(struct file *file, void 
*priv,
pix-height = solo_dev-video_vsize  1;
}
 
-   if (pix-field == V4L2_FIELD_ANY)
-   pix-field = V4L2_FIELD_INTERLACED;
-   else if (pix-field != V4L2_FIELD_INTERLACED)
+   switch (pix-field) {
+   case V4L2_FIELD_NONE:
+   case V4L2_FIELD_INTERLACED:
+   break;
+   case V4L2_FIELD_ANY:
+   default:
pix-field = V4L2_FIELD_INTERLACED;
+   break;
+   }
 
/* Just set these */
pix-colorspace = V4L2_COLORSPACE_SMPTE170M;
pix-sizeimage = FRAME_BUF_SIZE;
+   pix-priv = 0;
 
return 0;
 }
@@ -1081,6 +1080,15 @@ static int solo_enc_set_fmt_cap(struct file *file, void 
*priv,
mutex_lock(solo_enc-enable_lock);
 
ret = solo_enc_try_fmt_cap(file, priv, f);
+   if (ret)
+   return ret;
+
+   /* We cannot change width/height in mid read */
+   if (!ret  atomic_read(solo_enc-readers)  0) {
+   if (pix-width != solo_enc-width ||
+   pix-height != solo_enc-height)
+   ret = -EBUSY;
+   }
if (ret) {
mutex_unlock(solo_enc-enable_lock);
return ret;
@@ -1116,6 +1124,7 @@ static int solo_enc_get_fmt_cap(struct file *file, void 
*priv,
 V4L2_FIELD_NONE;
pix-sizeimage = FRAME_BUF_SIZE;
pix-colorspace = V4L2_COLORSPACE_SMPTE170M;
+   pix-priv = 0;
 
return 0;
 }
@@ -1205,7 +1214,8 @@ static int solo_enum_framesizes(struct file *file, void 
*priv,
struct solo_enc_fh *fh = priv;
struct solo_dev *solo_dev = fh-enc-solo_dev;
 
-   if (fsize-pixel_format != V4L2_PIX_FMT_MPEG)
+   if (fsize-pixel_format != V4L2_PIX_FMT_MPEG 
+   fsize-pixel_format != V4L2_PIX_FMT_MJPEG)
return -EINVAL;
 
switch (fsize-index) {
@@ -1232,16 +1242,24 @@ static int solo_enum_frameintervals(struct file *file, 
void *priv,
struct solo_enc_fh *fh = priv;
struct solo_dev *solo_dev = fh-enc-solo_dev;
 
-   if (fintv-pixel_format != V4L2_PIX_FMT_MPEG || fintv-index)
+   if (fintv-pixel_format != V4L2_PIX_FMT_MPEG 
+   fintv-pixel_format != V4L2_PIX_FMT_MJPEG)
+   return -EINVAL;
+   if (fintv-index)
+   return -EINVAL;
+   if ((fintv-width != solo_dev-video_hsize  1 ||
+fintv-height != solo_dev-video_vsize) 
+   (fintv-width != solo_dev-video_hsize ||
+fintv-height != solo_dev-video_vsize  1))
return -EINVAL;
 
fintv-type = V4L2_FRMIVAL_TYPE_STEPWISE;
 
-   fintv-stepwise.min.numerator = solo_dev-fps;
-   fintv-stepwise.min.denominator = 1;
+   fintv-stepwise.min.denominator = solo_dev-fps;
+   fintv-stepwise.min.numerator = 15;
 
-   fintv-stepwise.max.numerator = solo_dev-fps;
-   fintv-stepwise.max.denominator = 15;
+   fintv-stepwise.max.denominator = solo_dev-fps;
+   fintv-stepwise.max.numerator = 1;
 
fintv-stepwise.step.numerator = 1;
fintv-stepwise.step.denominator = 1;
@@ -1298,6 +1316,7 @@ static int solo_s_parm(struct file *file, void *priv,
solo_enc-interval = cp-timeperframe.numerator;
 
cp-capability = 

[REVIEW PATCH 06/19] solo6x10: add support for prio and control event handling.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/v4l2-enc.c |   19 +--
 drivers/staging/media/solo6x10/v4l2.c |   17 -
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index bf52a73..366f2b3 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -29,6 +29,7 @@
 
 #include media/v4l2-ioctl.h
 #include media/v4l2-common.h
+#include media/v4l2-event.h
 #include media/videobuf-dma-sg.h
 
 #include solo6x10.h
@@ -46,7 +47,8 @@ enum solo_enc_types {
 };
 
 struct solo_enc_fh {
-   struct  solo_enc_dev *enc;
+   struct v4l2_fh  fh;
+   struct solo_enc_dev *enc;
u32 fmt;
u8  enc_on;
enum solo_enc_types type;
@@ -823,7 +825,11 @@ static unsigned int solo_enc_poll(struct file *file,
  struct poll_table_struct *wait)
 {
struct solo_enc_fh *fh = file-private_data;
+   unsigned long req_events = poll_requested_events(wait);
+   unsigned res = v4l2_ctrl_poll(file, wait);
 
+   if (!(req_events  (POLLIN | POLLRDNORM)))
+   return res;
return videobuf_poll_stream(file, fh-vidq, wait);
 }
 
@@ -892,6 +898,7 @@ static int solo_enc_open(struct file *file)
return -ENOMEM;
}
 
+   v4l2_fh_init(fh-fh, video_devdata(file));
fh-enc = solo_enc;
spin_lock_init(fh-av_lock);
file-private_data = fh;
@@ -906,7 +913,7 @@ static int solo_enc_open(struct file *file)
V4L2_FIELD_INTERLACED,
sizeof(struct solo_videobuf),
fh, NULL);
-
+   v4l2_fh_add(fh-fh);
return 0;
 }
 
@@ -931,6 +938,8 @@ static int solo_enc_release(struct file *file)
struct solo_dev *solo_dev = fh-enc-solo_dev;
 
solo_enc_off(fh);
+   v4l2_fh_del(fh-fh);
+   v4l2_fh_exit(fh-fh);
 
videobuf_stop(fh-vidq);
videobuf_mmap_free(fh-vidq);
@@ -1063,6 +1072,7 @@ static int solo_enc_try_fmt_cap(struct file *file, void 
*priv,
/* Just set these */
pix-colorspace = V4L2_COLORSPACE_SMPTE170M;
pix-sizeimage = FRAME_BUF_SIZE;
+   pix-bytesperline = 0;
pix-priv = 0;
 
return 0;
@@ -1417,6 +1427,10 @@ static const struct v4l2_ioctl_ops solo_enc_ioctl_ops = {
/* Video capture parameters */
.vidioc_s_parm  = solo_s_parm,
.vidioc_g_parm  = solo_g_parm,
+   /* Logging and events */
+   .vidioc_log_status  = v4l2_ctrl_log_status,
+   .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
+   .vidioc_unsubscribe_event   = v4l2_event_unsubscribe,
 };
 
 static const struct video_device solo_enc_template = {
@@ -1516,6 +1530,7 @@ static struct solo_enc_dev *solo_enc_alloc(struct 
solo_dev *solo_dev,
*solo_enc-vfd = solo_enc_template;
solo_enc-vfd-v4l2_dev = solo_dev-v4l2_dev;
solo_enc-vfd-ctrl_handler = hdl;
+   set_bit(V4L2_FL_USE_FH_PRIO, solo_enc-vfd-flags);
ret = video_register_device(solo_enc-vfd, VFL_TYPE_GRABBER, nr);
if (ret  0) {
video_device_release(solo_enc-vfd);
diff --git a/drivers/staging/media/solo6x10/v4l2.c 
b/drivers/staging/media/solo6x10/v4l2.c
index a606c5c..fe09180 100644
--- a/drivers/staging/media/solo6x10/v4l2.c
+++ b/drivers/staging/media/solo6x10/v4l2.c
@@ -29,6 +29,7 @@
 
 #include media/v4l2-ioctl.h
 #include media/v4l2-common.h
+#include media/v4l2-event.h
 #include media/videobuf-dma-contig.h
 
 #include solo6x10.h
@@ -45,6 +46,7 @@
 
 /* Simple file handle */
 struct solo_filehandle {
+   struct v4l2_fh  fh;
struct solo_dev *solo_dev;
struct videobuf_queue   vidq;
struct task_struct  *kthread;
@@ -402,8 +404,12 @@ static unsigned int solo_v4l2_poll(struct file *file,
   struct poll_table_struct *wait)
 {
struct solo_filehandle *fh = file-private_data;
+   unsigned long req_events = poll_requested_events(wait);
+   unsigned res = v4l2_ctrl_poll(file, wait);
 
-   return videobuf_poll_stream(file, fh-vidq, wait);
+   if (!(req_events  (POLLIN | POLLRDNORM)))
+   return res;
+   return res | videobuf_poll_stream(file, fh-vidq, wait);
 }
 
 static int solo_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
@@ -423,6 +429,7 @@ static int solo_v4l2_open(struct file *file)
if (fh == NULL)
return -ENOMEM;
 
+   v4l2_fh_init(fh-fh, video_devdata(file));
spin_lock_init(fh-slock);
INIT_LIST_HEAD(fh-vidq_active);
fh-solo_dev = solo_dev;
@@ -440,6 +447,7 @@ static int 

[REVIEW PATCH 07/19] solo6x10: move global fields in solo_dev_fh to solo_dev.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

All fields in solo_dev_fh do not belong there since they refer to global
properties. After moving all these fields to solo_dev the solo_dev_fh
struct can be removed completely.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/solo6x10.h |7 +
 drivers/staging/media/solo6x10/v4l2.c |  231 -
 2 files changed, 101 insertions(+), 137 deletions(-)

diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index 82be88c..361f41f 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -250,6 +250,13 @@ struct solo_dev {
void*vh_buf;
dma_addr_t  vh_dma;
int vh_size;
+
+   /* Buffer handling */
+   struct videobuf_queue   vidq;
+   struct task_struct  *kthread;
+   spinlock_t  slock;
+   int old_write;
+   struct list_headvidq_active;
 };
 
 static inline u32 solo_reg_read(struct solo_dev *solo_dev, int reg)
diff --git a/drivers/staging/media/solo6x10/v4l2.c 
b/drivers/staging/media/solo6x10/v4l2.c
index fe09180..64595ef 100644
--- a/drivers/staging/media/solo6x10/v4l2.c
+++ b/drivers/staging/media/solo6x10/v4l2.c
@@ -44,17 +44,6 @@
 
 #define MIN_VID_BUFFERS2
 
-/* Simple file handle */
-struct solo_filehandle {
-   struct v4l2_fh  fh;
-   struct solo_dev *solo_dev;
-   struct videobuf_queue   vidq;
-   struct task_struct  *kthread;
-   spinlock_t  slock;
-   int old_write;
-   struct list_headvidq_active;
-};
-
 static inline void erase_on(struct solo_dev *solo_dev)
 {
solo_reg_write(solo_dev, SOLO_VO_DISP_ERASE, SOLO_VO_DISP_ERASE_ON);
@@ -202,10 +191,9 @@ static int solo_v4l2_set_ch(struct solo_dev *solo_dev, u8 
ch)
return 0;
 }
 
-static void solo_fillbuf(struct solo_filehandle *fh,
+static void solo_fillbuf(struct solo_dev *solo_dev,
 struct videobuf_buffer *vb)
 {
-   struct solo_dev *solo_dev = fh-solo_dev;
dma_addr_t vbuf;
unsigned int fdma_addr;
int error = -1;
@@ -216,7 +204,7 @@ static void solo_fillbuf(struct solo_filehandle *fh,
goto finish_buf;
 
if (erase_off(solo_dev)) {
-   void *p = videobuf_queue_to_vaddr(fh-vidq, vb);
+   void *p = videobuf_queue_to_vaddr(solo_dev-vidq, vb);
int image_size = solo_image_size(solo_dev);
for (i = 0; i  image_size; i += 2) {
((u8 *)p)[i] = 0x80;
@@ -224,7 +212,7 @@ static void solo_fillbuf(struct solo_filehandle *fh,
}
error = 0;
} else {
-   fdma_addr = SOLO_DISP_EXT_ADDR + (fh-old_write *
+   fdma_addr = SOLO_DISP_EXT_ADDR + (solo_dev-old_write *
(SOLO_HW_BPL * solo_vlines(solo_dev)));
 
error = solo_p2m_dma_t(solo_dev, 0, vbuf, fdma_addr,
@@ -243,7 +231,7 @@ finish_buf:
wake_up(vb-done);
 }
 
-static void solo_thread_try(struct solo_filehandle *fh)
+static void solo_thread_try(struct solo_dev *solo_dev)
 {
struct videobuf_buffer *vb;
 
@@ -253,38 +241,37 @@ static void solo_thread_try(struct solo_filehandle *fh)
unsigned int cur_write;
 
cur_write = SOLO_VI_STATUS0_PAGE(
-   solo_reg_read(fh-solo_dev, SOLO_VI_STATUS0));
-   if (cur_write == fh-old_write)
+   solo_reg_read(solo_dev, SOLO_VI_STATUS0));
+   if (cur_write == solo_dev-old_write)
return;
 
-   spin_lock(fh-slock);
+   spin_lock(solo_dev-slock);
 
-   if (list_empty(fh-vidq_active))
+   if (list_empty(solo_dev-vidq_active))
break;
 
-   vb = list_first_entry(fh-vidq_active, struct videobuf_buffer,
+   vb = list_first_entry(solo_dev-vidq_active, struct 
videobuf_buffer,
  queue);
 
if (!waitqueue_active(vb-done))
break;
 
-   fh-old_write = cur_write;
+   solo_dev-old_write = cur_write;
list_del(vb-queue);
vb-state = VIDEOBUF_ACTIVE;
 
-   spin_unlock(fh-slock);
+   spin_unlock(solo_dev-slock);
 
-   solo_fillbuf(fh, vb);
+   solo_fillbuf(solo_dev, vb);
}
 
-   assert_spin_locked(fh-slock);
-   spin_unlock(fh-slock);
+   assert_spin_locked(solo_dev-slock);
+   spin_unlock(solo_dev-slock);
 }
 
 static int solo_thread(void *data)
 {
-   struct solo_filehandle *fh = data;
-   struct solo_dev *solo_dev = fh-solo_dev;
+   struct solo_dev *solo_dev 

[REVIEW PATCH 03/19] solo6x10: add v4l2_device.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add support for struct v4l2_device.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/core.c |8 ++--
 drivers/staging/media/solo6x10/solo6x10.h |2 ++
 drivers/staging/media/solo6x10/v4l2-enc.c |2 +-
 drivers/staging/media/solo6x10/v4l2.c |2 +-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/solo6x10/core.c 
b/drivers/staging/media/solo6x10/core.c
index 27ae75a..271759f 100644
--- a/drivers/staging/media/solo6x10/core.c
+++ b/drivers/staging/media/solo6x10/core.c
@@ -180,6 +180,7 @@ static void free_solo_dev(struct solo_dev *solo_dev)
 
pci_release_regions(pdev);
pci_disable_device(pdev);
+   v4l2_device_unregister(solo_dev-v4l2_dev);
pci_set_drvdata(pdev, NULL);
 
kfree(solo_dev);
@@ -510,7 +511,9 @@ static int solo_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
solo_dev-type = id-driver_data;
solo_dev-pdev = pdev;
spin_lock_init(solo_dev-reg_io_lock);
-   pci_set_drvdata(pdev, solo_dev);
+   ret = v4l2_device_register(pdev-dev, solo_dev-v4l2_dev);
+   if (ret)
+   goto fail_probe;
 
/* Only for during init */
solo_dev-p2m_jiffies = msecs_to_jiffies(100);
@@ -677,7 +680,8 @@ fail_probe:
 
 static void solo_pci_remove(struct pci_dev *pdev)
 {
-   struct solo_dev *solo_dev = pci_get_drvdata(pdev);
+   struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev);
+   struct solo_dev *solo_dev = container_of(v4l2_dev, struct solo_dev, 
v4l2_dev);
 
free_solo_dev(solo_dev);
 }
diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index a8924a9..77041f5 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -37,6 +37,7 @@
 
 #include linux/videodev2.h
 #include media/v4l2-dev.h
+#include media/v4l2-device.h
 #include media/videobuf-core.h
 
 #include registers.h
@@ -178,6 +179,7 @@ struct solo_dev {
u32 irq_mask;
u32 motion_mask;
spinlock_t  reg_io_lock;
+   struct v4l2_device  v4l2_dev;
 
/* tw28xx accounting */
u8  tw2865, tw2864, tw2815;
diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index 8f02af2..c4b2a34 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -1670,7 +1670,7 @@ static struct solo_enc_dev *solo_enc_alloc(struct 
solo_dev *solo_dev,
solo_enc-ch = ch;
 
*solo_enc-vfd = solo_enc_template;
-   solo_enc-vfd-parent = solo_dev-pdev-dev;
+   solo_enc-vfd-v4l2_dev = solo_dev-v4l2_dev;
ret = video_register_device(solo_enc-vfd, VFL_TYPE_GRABBER, nr);
if (ret  0) {
video_device_release(solo_enc-vfd);
diff --git a/drivers/staging/media/solo6x10/v4l2.c 
b/drivers/staging/media/solo6x10/v4l2.c
index d2f6eb6..ae1c119 100644
--- a/drivers/staging/media/solo6x10/v4l2.c
+++ b/drivers/staging/media/solo6x10/v4l2.c
@@ -823,7 +823,7 @@ int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr)
return -ENOMEM;
 
*solo_dev-vfd = solo_v4l2_template;
-   solo_dev-vfd-parent = solo_dev-pdev-dev;
+   solo_dev-vfd-v4l2_dev = solo_dev-v4l2_dev;
 
ret = video_register_device(solo_dev-vfd, VFL_TYPE_GRABBER, nr);
if (ret  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


[REVIEW PATCH 04/19] solo6x10: add control framework.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Note that the MOTION_THRESHOLD functionality has been temporarily reduced:
only the global threshold can be set, not the per-block. This will be
addressed in a later patch: controls are not the proper way to do this.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/solo6x10.h |   15 +-
 drivers/staging/media/solo6x10/tw28.c |   12 +-
 drivers/staging/media/solo6x10/tw28.h |1 +
 drivers/staging/media/solo6x10/v4l2-enc.c |  350 -
 drivers/staging/media/solo6x10/v4l2.c |   83 +++
 5 files changed, 132 insertions(+), 329 deletions(-)

diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index 77041f5..82be88c 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -38,6 +38,7 @@
 #include linux/videodev2.h
 #include media/v4l2-dev.h
 #include media/v4l2-device.h
+#include media/v4l2-ctrls.h
 #include media/videobuf-core.h
 
 #include registers.h
@@ -100,12 +101,12 @@
 #define V4L2_BUF_FLAG_MOTION_ON0x0400
 #define V4L2_BUF_FLAG_MOTION_DETECTED  0x0800
 #endif
-#ifndef V4L2_CID_MOTION_ENABLE
-#define PRIVATE_CIDS
-#define V4L2_CID_MOTION_ENABLE (V4L2_CID_PRIVATE_BASE+0)
-#define V4L2_CID_MOTION_THRESHOLD  (V4L2_CID_PRIVATE_BASE+1)
-#define V4L2_CID_MOTION_TRACE  (V4L2_CID_PRIVATE_BASE+2)
-#endif
+
+#define SOLO_CID_CUSTOM_BASE   (V4L2_CID_USER_BASE | 0xf000)
+#define V4L2_CID_MOTION_ENABLE (SOLO_CID_CUSTOM_BASE+0)
+#define V4L2_CID_MOTION_THRESHOLD  (SOLO_CID_CUSTOM_BASE+1)
+#define V4L2_CID_MOTION_TRACE  (SOLO_CID_CUSTOM_BASE+2)
+#define V4L2_CID_OSD_TEXT  (SOLO_CID_CUSTOM_BASE+3)
 
 enum SOLO_I2C_STATE {
IIC_STATE_IDLE,
@@ -137,6 +138,7 @@ struct solo_p2m_dev {
 struct solo_enc_dev {
struct solo_dev *solo_dev;
/* V4L2 Items */
+   struct v4l2_ctrl_handler hdl;
struct video_device *vfd;
/* General accounting */
struct mutexenable_lock;
@@ -207,6 +209,7 @@ struct solo_dev {
unsigned intframe_blank;
u8  cur_disp_ch;
wait_queue_head_t   disp_thread_wait;
+   struct v4l2_ctrl_handler disp_hdl;
 
/* V4L2 Encoder items */
struct solo_enc_dev *v4l2_enc[SOLO_MAX_CHANNELS];
diff --git a/drivers/staging/media/solo6x10/tw28.c 
b/drivers/staging/media/solo6x10/tw28.c
index 365ab10..69baf82 100644
--- a/drivers/staging/media/solo6x10/tw28.c
+++ b/drivers/staging/media/solo6x10/tw28.c
@@ -660,6 +660,11 @@ u16 tw28_get_audio_status(struct solo_dev *solo_dev)
 }
 #endif
 
+bool tw28_has_sharpness(struct solo_dev *solo_dev, u8 ch)
+{
+   return is_tw286x(solo_dev, ch / 4);
+}
+
 int tw28_set_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, u8 ch,
  s32 val)
 {
@@ -676,8 +681,6 @@ int tw28_set_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, 
u8 ch,
switch (ctrl) {
case V4L2_CID_SHARPNESS:
/* Only 286x has sharpness */
-   if (val  0x0f || val  0)
-   return -ERANGE;
if (is_tw286x(solo_dev, chip_num)) {
u8 v = solo_i2c_readbyte(solo_dev, SOLO_I2C_TW,
 TW_CHIP_OFFSET_ADDR(chip_num),
@@ -687,8 +690,9 @@ int tw28_set_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, 
u8 ch,
solo_i2c_writebyte(solo_dev, SOLO_I2C_TW,
   TW_CHIP_OFFSET_ADDR(chip_num),
   TW286x_SHARPNESS(chip_num), v);
-   } else if (val != 0)
-   return -ERANGE;
+   } else {
+   return -EINVAL;
+   }
break;
 
case V4L2_CID_HUE:
diff --git a/drivers/staging/media/solo6x10/tw28.h 
b/drivers/staging/media/solo6x10/tw28.h
index a03b429..1a02c87 100644
--- a/drivers/staging/media/solo6x10/tw28.h
+++ b/drivers/staging/media/solo6x10/tw28.h
@@ -55,6 +55,7 @@ int solo_tw28_init(struct solo_dev *solo_dev);
 
 int tw28_set_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, u8 ch, s32 val);
 int tw28_get_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, u8 ch, s32 *val);
+bool tw28_has_sharpness(struct solo_dev *solo_dev, u8 ch);
 
 u8 tw28_get_audio_gain(struct solo_dev *solo_dev, u8 ch);
 void tw28_set_audio_gain(struct solo_dev *solo_dev, u8 ch, u8 val);
diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index c4b2a34..1fbd95f 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -119,41 +119,6 @@ static unsigned char vop_6110_pal_cif[] = {
0x01, 0x68, 0xce, 0x32, 0x28, 0x00, 0x00, 0x00,
 };
 
-
-static const u32 solo_user_ctrls[] = {
-   V4L2_CID_BRIGHTNESS,
-  

[REVIEW PATCH 13/19] solo6x10: drop video_type and add proper s_std support.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/core.c |   19 
 drivers/staging/media/solo6x10/disp.c |8 +
 drivers/staging/media/solo6x10/solo6x10.h |6 +++-
 drivers/staging/media/solo6x10/tw28.c |2 ++
 drivers/staging/media/solo6x10/v4l2-enc.c |   37 ++-
 drivers/staging/media/solo6x10/v4l2.c |   47 +++--
 6 files changed, 67 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/media/solo6x10/core.c 
b/drivers/staging/media/solo6x10/core.c
index b7e5d5e..00fb35a 100644
--- a/drivers/staging/media/solo6x10/core.c
+++ b/drivers/staging/media/solo6x10/core.c
@@ -231,24 +231,6 @@ static ssize_t eeprom_show(struct device *dev, struct 
device_attribute *attr,
return count;
 }
 
-static ssize_t video_type_store(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf, size_t count)
-{
-   return -EPERM;
-}
-
-static ssize_t video_type_show(struct device *dev,
-  struct device_attribute *attr,
-  char *buf)
-{
-   struct solo_dev *solo_dev =
-   container_of(dev, struct solo_dev, dev);
-
-   return sprintf(buf, %s, solo_dev-video_type ==
-  SOLO_VO_FMT_TYPE_NTSC ? NTSC : PAL);
-}
-
 static ssize_t p2m_timeouts_show(struct device *dev,
 struct device_attribute *attr,
 char *buf)
@@ -435,7 +417,6 @@ static ssize_t sdram_show(struct file *file, struct kobject 
*kobj,
 
 static const struct device_attribute solo_dev_attrs[] = {
__ATTR(eeprom, 0640, eeprom_show, eeprom_store),
-   __ATTR(video_type, 0644, video_type_show, video_type_store),
__ATTR(p2m_timeout, 0644, p2m_timeout_show, p2m_timeout_store),
__ATTR_RO(p2m_timeouts),
__ATTR_RO(sdram_size),
diff --git a/drivers/staging/media/solo6x10/disp.c 
b/drivers/staging/media/solo6x10/disp.c
index ddd85e7..3dcaad9 100644
--- a/drivers/staging/media/solo6x10/disp.c
+++ b/drivers/staging/media/solo6x10/disp.c
@@ -39,10 +39,6 @@
 #define SOLO_MOT_FLAG_SIZE 1024
 #define SOLO_MOT_FLAG_AREA (SOLO_MOT_FLAG_SIZE * 16)
 
-static unsigned video_type;
-module_param(video_type, uint, 0644);
-MODULE_PARM_DESC(video_type, video_type (0 = NTSC/Default, 1 = PAL));
-
 static void solo_vin_config(struct solo_dev *solo_dev)
 {
solo_dev-vin_hstart = 8;
@@ -273,12 +269,10 @@ int solo_disp_init(struct solo_dev *solo_dev)
int i;
 
solo_dev-video_hsize = 704;
-   if (video_type == 0) {
-   solo_dev-video_type = SOLO_VO_FMT_TYPE_NTSC;
+   if (solo_dev-video_type == SOLO_VO_FMT_TYPE_NTSC) {
solo_dev-video_vsize = 240;
solo_dev-fps = 30;
} else {
-   solo_dev-video_type = SOLO_VO_FMT_TYPE_PAL;
solo_dev-video_vsize = 288;
solo_dev-fps = 25;
}
diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index 96ac299..56789b4 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -320,7 +320,7 @@ static inline void solo_irq_off(struct solo_dev *dev, u32 
mask)
solo_reg_write(dev, SOLO_IRQ_MASK, dev-irq_mask);
 }
 
-/* Init/exit routeines for subsystems */
+/* Init/exit routines for subsystems */
 int solo_disp_init(struct solo_dev *solo_dev);
 void solo_disp_exit(struct solo_dev *solo_dev);
 
@@ -373,6 +373,10 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
  struct solo_p2m_desc *desc, dma_addr_t desc_dma,
  int desc_cnt);
 
+/* Global s_std ioctl */
+int solo_set_video_type(struct solo_dev *solo_dev, bool type);
+void solo_update_mode(struct solo_enc_dev *solo_enc);
+
 /* Set the threshold for motion detection */
 int solo_set_motion_threshold(struct solo_dev *solo_dev, u8 ch, u16 val);
 int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch, u16 val,
diff --git a/drivers/staging/media/solo6x10/tw28.c 
b/drivers/staging/media/solo6x10/tw28.c
index 69baf82..6c77af8 100644
--- a/drivers/staging/media/solo6x10/tw28.c
+++ b/drivers/staging/media/solo6x10/tw28.c
@@ -576,6 +576,8 @@ int solo_tw28_init(struct solo_dev *solo_dev)
int i;
u8 value;
 
+   solo_dev-tw28_cnt = 0;
+
/* Detect techwell chip type(s) */
for (i = 0; i  solo_dev-nr_chans / 4; i++) {
value = solo_i2c_readbyte(solo_dev, SOLO_I2C_TW,
diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index dc1f8b3..93f0dc7 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -176,7 +176,7 @@ static void solo_motion_toggle(struct solo_enc_dev 

[REVIEW PATCH 10/19] solo6x10: convert the display node to vb2.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

As a consequence the ioctl op has been replaced by unlocked_ioctl.

Since we are now using the core lock the locking scheme has been
simplified as well.

The main reason for converting this driver to vb2 was that the locking
scheme in v4l2.c was hopeless. It was easier to just convert the driver
then to try and salvage a threading and videobuf nightmare.

The videobuf2 framework is far, far superior compared to the old videobuf.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/Kconfig|2 +-
 drivers/staging/media/solo6x10/solo6x10.h |7 +-
 drivers/staging/media/solo6x10/v4l2-enc.c |   12 --
 drivers/staging/media/solo6x10/v4l2.c |  289 ++---
 4 files changed, 103 insertions(+), 207 deletions(-)

diff --git a/drivers/staging/media/solo6x10/Kconfig 
b/drivers/staging/media/solo6x10/Kconfig
index f93b4ca..ec32776 100644
--- a/drivers/staging/media/solo6x10/Kconfig
+++ b/drivers/staging/media/solo6x10/Kconfig
@@ -1,8 +1,8 @@
 config SOLO6X10
tristate Softlogic 6x10 MPEG codec cards
depends on PCI  VIDEO_DEV  SND  I2C
-   select VIDEOBUF_DMA_SG
select VIDEOBUF2_DMA_SG
+   select VIDEOBUF2_DMA_CONTIG
select SND_PCM
---help---
  This driver supports the Softlogic based MPEG-4 and h.264 codec
diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index 5b21178..96ac299 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -39,7 +39,6 @@
 #include media/v4l2-dev.h
 #include media/v4l2-device.h
 #include media/v4l2-ctrls.h
-#include media/videobuf-core.h
 #include media/videobuf2-core.h
 
 #include registers.h
@@ -259,8 +258,6 @@ struct solo_dev {
/* Ring thread */
struct task_struct  *ring_thread;
wait_queue_head_t   ring_thread_wait;
-   atomic_tenc_users;
-   atomic_tdisp_users;
 
/* VOP_HEADER handling */
void*vh_buf;
@@ -268,8 +265,10 @@ struct solo_dev {
int vh_size;
 
/* Buffer handling */
-   struct videobuf_queue   vidq;
+   struct vb2_queuevidq;
+   struct vb2_alloc_ctx*alloc_ctx;
struct task_struct  *kthread;
+   struct mutexlock;
spinlock_t  slock;
int old_write;
struct list_headvidq_active;
diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index eb82299..dc1f8b3 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -41,11 +41,6 @@
 #define MP4_QS 16
 #define DMA_ALIGN  4096
 
-struct solo_videobuf {
-   struct videobuf_buffer  vb;
-   unsigned intflags;
-};
-
 /* 6010 M4V */
 static unsigned char vop_6010_ntsc_d1[] = {
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x20,
@@ -672,9 +667,6 @@ static void solo_enc_buf_queue(struct vb2_buffer *vb)
 
 static int solo_ring_start(struct solo_dev *solo_dev)
 {
-   if (atomic_inc_return(solo_dev-enc_users)  1)
-   return 0;
-
solo_dev-ring_thread = kthread_run(solo_ring_thread, solo_dev,
SOLO6X10_NAME _ring);
if (IS_ERR(solo_dev-ring_thread)) {
@@ -690,9 +682,6 @@ static int solo_ring_start(struct solo_dev *solo_dev)
 
 static void solo_ring_stop(struct solo_dev *solo_dev)
 {
-   if (atomic_dec_return(solo_dev-enc_users)  0)
-   return;
-
if (solo_dev-ring_thread) {
kthread_stop(solo_dev-ring_thread);
solo_dev-ring_thread = NULL;
@@ -1279,7 +1268,6 @@ int solo_enc_v4l2_init(struct solo_dev *solo_dev, 
unsigned nr)
 {
int i;
 
-   atomic_set(solo_dev-enc_users, 0);
init_waitqueue_head(solo_dev-ring_thread_wait);
 
solo_dev-vh_size = sizeof(struct vop_header);
diff --git a/drivers/staging/media/solo6x10/v4l2.c 
b/drivers/staging/media/solo6x10/v4l2.c
index 64595ef..6931950 100644
--- a/drivers/staging/media/solo6x10/v4l2.c
+++ b/drivers/staging/media/solo6x10/v4l2.c
@@ -30,7 +30,7 @@
 #include media/v4l2-ioctl.h
 #include media/v4l2-common.h
 #include media/v4l2-event.h
-#include media/videobuf-dma-contig.h
+#include media/videobuf2-dma-contig.h
 
 #include solo6x10.h
 #include tw28.h
@@ -192,19 +192,19 @@ static int solo_v4l2_set_ch(struct solo_dev *solo_dev, u8 
ch)
 }
 
 static void solo_fillbuf(struct solo_dev *solo_dev,
-struct videobuf_buffer *vb)
+struct vb2_buffer *vb)
 {
dma_addr_t vbuf;
unsigned int fdma_addr;
int error = -1;
int i;
 
-   vbuf = videobuf_to_dma_contig(vb);
+   vbuf = vb2_dma_contig_plane_dma_addr(vb, 0);
if 

[REVIEW PATCH 09/19] solo6x10: convert encoder nodes to vb2.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

As a consequence the ioctl op has been replaced by unlocked_ioctl.

Since we are now using the core lock the locking scheme has been
simplified as well.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/Kconfig|1 +
 drivers/staging/media/solo6x10/solo6x10.h |   13 +-
 drivers/staging/media/solo6x10/v4l2-enc.c |  505 -
 3 files changed, 140 insertions(+), 379 deletions(-)

diff --git a/drivers/staging/media/solo6x10/Kconfig 
b/drivers/staging/media/solo6x10/Kconfig
index 63352de..f93b4ca 100644
--- a/drivers/staging/media/solo6x10/Kconfig
+++ b/drivers/staging/media/solo6x10/Kconfig
@@ -2,6 +2,7 @@ config SOLO6X10
tristate Softlogic 6x10 MPEG codec cards
depends on PCI  VIDEO_DEV  SND  I2C
select VIDEOBUF_DMA_SG
+   select VIDEOBUF2_DMA_SG
select SND_PCM
---help---
  This driver supports the Softlogic based MPEG-4 and h.264 codec
diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index cf88db3..5b21178 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -40,6 +40,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-ctrls.h
 #include media/videobuf-core.h
+#include media/videobuf2-core.h
 
 #include registers.h
 
@@ -135,6 +136,11 @@ struct solo_p2m_dev {
 
 #define OSD_TEXT_MAX   44
 
+struct solo_vb2_buf {
+   struct vb2_buffer vb;
+   struct list_head list;
+};
+
 enum solo_enc_types {
SOLO_ENC_TYPE_STD,
SOLO_ENC_TYPE_EXT,
@@ -146,10 +152,8 @@ struct solo_enc_dev {
struct v4l2_ctrl_handler hdl;
struct video_device *vfd;
/* General accounting */
-   struct mutexenable_lock;
+   struct mutexlock;
spinlock_t  motion_lock;
-   atomic_treaders;
-   atomic_tmpeg_readers;
u8  ch;
u8  mode, gop, qp, interlaced, interval;
u8  bw_weight;
@@ -169,9 +173,8 @@ struct solo_enc_dev {
int jpeg_len;
 
u32 fmt;
-   u8  enc_on;
enum solo_enc_types type;
-   struct videobuf_queue   vidq;
+   struct vb2_queuevidq;
struct list_headvidq_active;
int desc_count;
int desc_nelts;
diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index 65609c1..eb82299 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -30,7 +30,7 @@
 #include media/v4l2-ioctl.h
 #include media/v4l2-common.h
 #include media/v4l2-event.h
-#include media/videobuf-dma-sg.h
+#include media/videobuf2-dma-sg.h
 
 #include solo6x10.h
 #include tw28.h
@@ -181,7 +181,6 @@ static void solo_motion_toggle(struct solo_enc_dev 
*solo_enc, int on)
spin_unlock_irqrestore(solo_enc-motion_lock, flags);
 }
 
-/* MUST be called with solo_enc-enable_lock held */
 static void solo_update_mode(struct solo_enc_dev *solo_enc)
 {
struct solo_dev *solo_dev = solo_enc-solo_dev;
@@ -264,43 +263,22 @@ static void solo_update_mode(struct solo_enc_dev 
*solo_enc)
   jpeg_dqt[solo_g_jpeg_qp(solo_dev, solo_enc-ch)], DQT_LEN);
 }
 
-/* MUST be called with solo_enc-enable_lock held */
-static int __solo_enc_on(struct solo_enc_dev *solo_enc)
+static int solo_enc_on(struct solo_enc_dev *solo_enc)
 {
u8 ch = solo_enc-ch;
struct solo_dev *solo_dev = solo_enc-solo_dev;
u8 interval;
 
-   BUG_ON(!mutex_is_locked(solo_enc-enable_lock));
-
-   if (solo_enc-enc_on)
-   return 0;
-
solo_update_mode(solo_enc);
 
-   /* Make sure to bw check on first reader */
-   if (!atomic_read(solo_enc-readers)) {
-   if (solo_enc-bw_weight  solo_dev-enc_bw_remain)
-   return -EBUSY;
-   else
-   solo_dev-enc_bw_remain -= solo_enc-bw_weight;
-   }
-
-   solo_enc-enc_on = 1;
+   /* Make sure to do a bandwidth check */
+   if (solo_enc-bw_weight  solo_dev-enc_bw_remain)
+   return -EBUSY;
+   solo_dev-enc_bw_remain -= solo_enc-bw_weight;
 
if (solo_enc-type == SOLO_ENC_TYPE_EXT)
solo_reg_write(solo_dev, SOLO_CAP_CH_COMP_ENA_E(ch), 1);
 
-   /* Reset the encoder if we are the first mpeg reader, else only reset
-* on the first mjpeg reader. */
-   if (solo_enc-fmt == V4L2_PIX_FMT_MPEG) {
-   atomic_inc(solo_enc-readers);
-   if (atomic_inc_return(solo_enc-mpeg_readers)  1)
-   return 0;
-   } else if (atomic_inc_return(solo_enc-readers)  1) {
-   return 0;
-   }
-
  

[REVIEW PATCH 17/19] solo6x10: fix sequence handling.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/solo6x10.h |2 ++
 drivers/staging/media/solo6x10/v4l2-enc.c |3 ++-
 drivers/staging/media/solo6x10/v4l2.c |3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index 56789b4..3313257 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -173,6 +173,7 @@ struct solo_enc_dev {
 
u32 fmt;
enum solo_enc_types type;
+   u32 sequence;
struct vb2_queuevidq;
struct list_headvidq_active;
int desc_count;
@@ -267,6 +268,7 @@ struct solo_dev {
/* Buffer handling */
struct vb2_queuevidq;
struct vb2_alloc_ctx*alloc_ctx;
+   u32 sequence;
struct task_struct  *kthread;
struct mutexlock;
spinlock_t  slock;
diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index ca87fb3..e53c985 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -269,6 +269,7 @@ static int solo_enc_on(struct solo_enc_dev *solo_enc)
/* Make sure to do a bandwidth check */
if (solo_enc-bw_weight  solo_dev-enc_bw_remain)
return -EBUSY;
+   solo_enc-sequence = 0;
solo_dev-enc_bw_remain -= solo_enc-bw_weight;
 
if (solo_enc-type == SOLO_ENC_TYPE_EXT)
@@ -522,7 +523,7 @@ static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc,
ret = solo_fill_jpeg(solo_enc, vb, vh);
 
if (!ret) {
-   vb-v4l2_buf.sequence++;
+   vb-v4l2_buf.sequence = solo_enc-sequence++;
vb-v4l2_buf.timestamp.tv_sec = vh-sec;
vb-v4l2_buf.timestamp.tv_usec = vh-usec;
}
diff --git a/drivers/staging/media/solo6x10/v4l2.c 
b/drivers/staging/media/solo6x10/v4l2.c
index 94db4c2..303d951 100644
--- a/drivers/staging/media/solo6x10/v4l2.c
+++ b/drivers/staging/media/solo6x10/v4l2.c
@@ -224,7 +224,7 @@ finish_buf:
if (!error) {
vb2_set_plane_payload(vb, 0,
solo_vlines(solo_dev) * solo_bytesperline(solo_dev));
-   vb-v4l2_buf.sequence++;
+   vb-v4l2_buf.sequence = solo_dev-sequence++;
v4l2_get_timestamp(vb-v4l2_buf.timestamp);
}
 
@@ -332,6 +332,7 @@ static int solo_start_streaming(struct vb2_queue *q, 
unsigned int count)
 {
struct solo_dev *solo_dev = vb2_get_drv_priv(q);
 
+   solo_dev-sequence = 0;
return solo_start_thread(solo_dev);
 }
 
-- 
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


[REVIEW PATCH 18/19] solo6x10: disable the 'priv' abuse.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/v4l2-enc.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index e53c985..642ebbf 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -860,8 +860,16 @@ static int solo_enc_set_fmt_cap(struct file *file, void 
*priv,
/* This does not change the encoder at all */
solo_enc-fmt = pix-pixelformat;
 
+   /*
+* More information is needed about these 'extended' types. As far
+* as I can tell these are basically additional video streams with
+* different MPEG encoding attributes that can run in parallel with
+* the main stream. If so, then this should be implemented as a
+* second video node. Abusing priv like this is certainly not the
+* right approach.
if (pix-priv)
solo_enc-type = SOLO_ENC_TYPE_EXT;
+*/
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


[REVIEW PATCH 15/19] solo6x10: small big-endian fix.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/disp.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/solo6x10/disp.c 
b/drivers/staging/media/solo6x10/disp.c
index 3dcaad9..7007006 100644
--- a/drivers/staging/media/solo6x10/disp.c
+++ b/drivers/staging/media/solo6x10/disp.c
@@ -181,7 +181,7 @@ static int solo_dma_vin_region(struct solo_dev *solo_dev, 
u32 off,
int ret = 0;
 
for (i = 0; i  sizeof(buf)  1; i++)
-   buf[i] = val;
+   buf[i] = cpu_to_le16(val);
 
for (i = 0; i  reg_size; i += sizeof(buf))
ret |= solo_p2m_dma(solo_dev, 1, buf,
-- 
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


[REVIEW PATCH 16/19] solo6x10: use V4L2_PIX_FMT_MPEG4, not _FMT_MPEG

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

FMT_MPEG is for multiplexed streams, not elementary streams. The same is
true for the V4L2_CID_MPEG_VIDEO_ENCODING control.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/v4l2-enc.c |   18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index 93f0dc7..ca87fb3 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -516,7 +516,7 @@ static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc,
vb-v4l2_buf.flags |= V4L2_BUF_FLAG_MOTION_DETECTED;
}
 
-   if (solo_enc-fmt == V4L2_PIX_FMT_MPEG)
+   if (solo_enc-fmt == V4L2_PIX_FMT_MPEG4)
ret = solo_fill_mpeg(solo_enc, vb, vh);
else
ret = solo_fill_jpeg(solo_enc, vb, vh);
@@ -779,7 +779,7 @@ static int solo_enc_enum_fmt_cap(struct file *file, void 
*priv,
 {
switch (f-index) {
case 0:
-   f-pixelformat = V4L2_PIX_FMT_MPEG;
+   f-pixelformat = V4L2_PIX_FMT_MPEG4;
strcpy(f-description, MPEG-4 AVC);
break;
case 1:
@@ -802,7 +802,7 @@ static int solo_enc_try_fmt_cap(struct file *file, void 
*priv,
struct solo_dev *solo_dev = solo_enc-solo_dev;
struct v4l2_pix_format *pix = f-fmt.pix;
 
-   if (pix-pixelformat != V4L2_PIX_FMT_MPEG 
+   if (pix-pixelformat != V4L2_PIX_FMT_MPEG4 
pix-pixelformat != V4L2_PIX_FMT_MJPEG)
return -EINVAL;
 
@@ -907,7 +907,7 @@ static int solo_enum_framesizes(struct file *file, void 
*priv,
struct solo_enc_dev *solo_enc = video_drvdata(file);
struct solo_dev *solo_dev = solo_enc-solo_dev;
 
-   if (fsize-pixel_format != V4L2_PIX_FMT_MPEG 
+   if (fsize-pixel_format != V4L2_PIX_FMT_MPEG4 
fsize-pixel_format != V4L2_PIX_FMT_MJPEG)
return -EINVAL;
 
@@ -935,7 +935,7 @@ static int solo_enum_frameintervals(struct file *file, void 
*priv,
struct solo_enc_dev *solo_enc = video_drvdata(file);
struct solo_dev *solo_dev = solo_enc-solo_dev;
 
-   if (fintv-pixel_format != V4L2_PIX_FMT_MPEG 
+   if (fintv-pixel_format != V4L2_PIX_FMT_MPEG4 
fintv-pixel_format != V4L2_PIX_FMT_MJPEG)
return -EINVAL;
if (fintv-index)
@@ -1024,8 +1024,6 @@ static int solo_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_SHARPNESS:
return tw28_set_ctrl_val(solo_dev, ctrl-id, solo_enc-ch,
 ctrl-val);
-   case V4L2_CID_MPEG_VIDEO_ENCODING:
-   return 0;
case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
solo_enc-gop = ctrl-val;
return 0;
@@ -1172,10 +1170,6 @@ static struct solo_enc_dev *solo_enc_alloc(struct 
solo_dev *solo_dev,
if (tw28_has_sharpness(solo_dev, ch))
v4l2_ctrl_new_std(hdl, solo_ctrl_ops,
V4L2_CID_SHARPNESS, 0, 15, 1, 0);
-   v4l2_ctrl_new_std_menu(hdl, solo_ctrl_ops,
-   V4L2_CID_MPEG_VIDEO_ENCODING,
-   V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC, 3,
-   V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC);
v4l2_ctrl_new_std(hdl, solo_ctrl_ops,
V4L2_CID_MPEG_VIDEO_GOP_SIZE, 1, 255, 1, solo_dev-fps);
v4l2_ctrl_new_custom(hdl, solo_motion_threshold_ctrl, NULL);
@@ -1191,7 +1185,7 @@ static struct solo_enc_dev *solo_enc_alloc(struct 
solo_dev *solo_dev,
mutex_init(solo_enc-lock);
spin_lock_init(solo_enc-av_lock);
INIT_LIST_HEAD(solo_enc-vidq_active);
-   solo_enc-fmt = V4L2_PIX_FMT_MPEG;
+   solo_enc-fmt = V4L2_PIX_FMT_MPEG4;
solo_enc-type = SOLO_ENC_TYPE_STD;
 
solo_enc-qp = SOLO_DEFAULT_QP;
-- 
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


[REVIEW PATCH 14/19] solo6x10: also stop DMA if the SOLO_PCI_ERR_P2M_DESC is raised.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Otherwise the computer will hang.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/p2m.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/solo6x10/p2m.c 
b/drivers/staging/media/solo6x10/p2m.c
index 2292061..013f177 100644
--- a/drivers/staging/media/solo6x10/p2m.c
+++ b/drivers/staging/media/solo6x10/p2m.c
@@ -197,7 +197,7 @@ void solo_p2m_error_isr(struct solo_dev *solo_dev)
struct solo_p2m_dev *p2m_dev;
int i;
 
-   if (!(err  SOLO_PCI_ERR_P2M))
+   if (!(err  (SOLO_PCI_ERR_P2M | SOLO_PCI_ERR_P2M_DESC)))
return;
 
for (i = 0; i  SOLO_NR_P2M; i++) {
-- 
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


[REVIEW PATCH 12/19] solo6x10: add call to pci_dma_mapping_error.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Check the result of the dma mapping.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/p2m.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/solo6x10/p2m.c 
b/drivers/staging/media/solo6x10/p2m.c
index 3ed4d58..2292061 100644
--- a/drivers/staging/media/solo6x10/p2m.c
+++ b/drivers/staging/media/solo6x10/p2m.c
@@ -51,6 +51,8 @@ int solo_p2m_dma(struct solo_dev *solo_dev, int wr,
 
dma_addr = pci_map_single(solo_dev-pdev, sys_addr, size,
  wr ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
+   if (pci_dma_mapping_error(solo_dev-pdev, dma_addr))
+   return -ENOMEM;
 
ret = solo_p2m_dma_t(solo_dev, wr, dma_addr, ext_addr, size,
 repeat, ext_size);
-- 
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


[REVIEW PATCH 19/19] solo6x10: clean up motion detection handling.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

An earlier patch temporarily disabled regional motion detection. This patch
adds it back: the 'Motion Detection Enable' control is now a 'Motion Detection 
Mode'.
And to set/get the regional thresholds two new ioctls were added to get/set 
those
thresholds.

The BUF_FLAG constants were also updated to prevent clashing with existing 
buffer
flags.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/disp.c |   37 +---
 drivers/staging/media/solo6x10/solo6x10.h |   27 +++--
 drivers/staging/media/solo6x10/v4l2-enc.c |   87 -
 3 files changed, 97 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/media/solo6x10/disp.c 
b/drivers/staging/media/solo6x10/disp.c
index 7007006..78070c8 100644
--- a/drivers/staging/media/solo6x10/disp.c
+++ b/drivers/staging/media/solo6x10/disp.c
@@ -201,31 +201,22 @@ int solo_set_motion_threshold(struct solo_dev *solo_dev, 
u8 ch, u16 val)
   val, SOLO_MOT_THRESH_SIZE);
 }
 
-int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch, u16 val,
-  u16 block)
+int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch,
+   const struct solo_motion_thresholds *thresholds)
 {
-   u16 buf[64];
-   u32 addr;
-   int re;
-
-   addr = SOLO_MOTION_EXT_ADDR(solo_dev) +
-   SOLO_MOT_FLAG_AREA +
-   (SOLO_MOT_THRESH_SIZE * 2 * ch) +
-   (block * 2);
-
-   /* Read and write only on a 128-byte boundary; 4-byte writes with
-  solo_p2m_dma silently failed. Bluecherry bug #908. */
-   re = solo_p2m_dma(solo_dev, 0, buf, addr  ~0x7f, sizeof(buf), 0, 0);
-   if (re)
-   return re;
-
-   buf[(addr  0x7f) / 2] = val;
-
-   re = solo_p2m_dma(solo_dev, 1, buf, addr  ~0x7f, sizeof(buf), 0, 0);
-   if (re)
-   return re;
+   u32 off = SOLO_MOT_FLAG_AREA + ch * SOLO_MOT_THRESH_SIZE * 2;
+   u16 buf[SOLO_MOTION_SZ];
+   int x, y;
+   int ret = 0;
 
-   return 0;
+   for (y = 0; y  SOLO_MOTION_SZ; y++) {
+   for (x = 0; x  SOLO_MOTION_SZ; x++)
+   buf[x] = cpu_to_le16(thresholds-thresholds[y][x]);
+   ret |= solo_p2m_dma(solo_dev, 1, buf,
+   SOLO_MOTION_EXT_ADDR(solo_dev) + off + y * sizeof(buf),
+   sizeof(buf), 0, 0);
+   }
+   return ret;
 }
 
 /* First 8k is motion flag (512 bytes * 16). Following that is an 8k+8k
diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index 3313257..1d08dbc 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -98,16 +98,30 @@
 #define SOLO_DEFAULT_QP3
 
 #ifndef V4L2_BUF_FLAG_MOTION_ON
-#define V4L2_BUF_FLAG_MOTION_ON0x0400
-#define V4L2_BUF_FLAG_MOTION_DETECTED  0x0800
+#define V4L2_BUF_FLAG_MOTION_ON0x1
+#define V4L2_BUF_FLAG_MOTION_DETECTED  0x2
 #endif
 
 #define SOLO_CID_CUSTOM_BASE   (V4L2_CID_USER_BASE | 0xf000)
-#define V4L2_CID_MOTION_ENABLE (SOLO_CID_CUSTOM_BASE+0)
+#define V4L2_CID_MOTION_MODE   (SOLO_CID_CUSTOM_BASE+0)
 #define V4L2_CID_MOTION_THRESHOLD  (SOLO_CID_CUSTOM_BASE+1)
 #define V4L2_CID_MOTION_TRACE  (SOLO_CID_CUSTOM_BASE+2)
 #define V4L2_CID_OSD_TEXT  (SOLO_CID_CUSTOM_BASE+3)
 
+/*
+ * Motion thresholds are in a table of 64x64 samples, with
+ * each sample representing 16x16 pixels of the source. In
+ * effect, 44x30 samples are used for NTSC, and 44x36 for PAL.
+ * The 5th sample on the 10th row is (10*64)+5 = 645.
+ */
+#define SOLO_MOTION_SZ (64)
+struct solo_motion_thresholds {
+   __u16   thresholds[SOLO_MOTION_SZ][SOLO_MOTION_SZ];
+};
+
+#define SOLO_IOC_G_MOTION_THRESHOLDS   _IOR('V', BASE_VIDIOC_PRIVATE+0, struct 
solo_motion_thresholds)
+#define SOLO_IOC_S_MOTION_THRESHOLDS   _IOW('V', BASE_VIDIOC_PRIVATE+1, struct 
solo_motion_thresholds)
+
 enum SOLO_I2C_STATE {
IIC_STATE_IDLE,
IIC_STATE_START,
@@ -157,6 +171,9 @@ struct solo_enc_dev {
u8  mode, gop, qp, interlaced, interval;
u8  bw_weight;
u16 motion_thresh;
+   struct solo_motion_thresholds motion_thresholds;
+   boolmotion_global;
+   boolmotion_enabled;
u16 width;
u16 height;
 
@@ -381,8 +398,8 @@ void solo_update_mode(struct solo_enc_dev *solo_enc);
 
 /* Set the threshold for motion detection */
 int solo_set_motion_threshold(struct solo_dev *solo_dev, u8 ch, u16 val);
-int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch, u16 val,
-  u16 block);
+int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch,
+  

[REVIEW PATCH 11/19] solo6x10: fix 'BUG: key ffff88081a2a9b58 not in .data!'

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Caused by a missing sysfs_attr_init().

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/core.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/solo6x10/core.c 
b/drivers/staging/media/solo6x10/core.c
index 271759f..b7e5d5e 100644
--- a/drivers/staging/media/solo6x10/core.c
+++ b/drivers/staging/media/solo6x10/core.c
@@ -480,6 +480,7 @@ static int solo_sysfs_init(struct solo_dev *solo_dev)
}
}
 
+   sysfs_attr_init(sdram_attr-attr);
sdram_attr-attr.name = sdram;
sdram_attr-attr.mode = 0440;
sdram_attr-read = sdram_show;
-- 
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


[REVIEW PATCH 08/19] solo6x10: move global fields in solo_enc_fh to solo_enc_dev.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

All fields in solo_enc_fh do not belong there since they refer to global
properties. After moving all these fields to solo_enc_dev the solo_dev_fh
struct can be removed completely.

Note that this also kills the 'listener' feature of this driver. This
feature (where multiple filehandles can read the video) is illegal in the
V4L2 API. Do this in userspace: it's much more efficient to copy memory
than it is to DMA to every listener.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/staging/media/solo6x10/solo6x10.h |   17 +-
 drivers/staging/media/solo6x10/v4l2-enc.c |  379 -
 2 files changed, 175 insertions(+), 221 deletions(-)

diff --git a/drivers/staging/media/solo6x10/solo6x10.h 
b/drivers/staging/media/solo6x10/solo6x10.h
index 361f41f..cf88db3 100644
--- a/drivers/staging/media/solo6x10/solo6x10.h
+++ b/drivers/staging/media/solo6x10/solo6x10.h
@@ -135,6 +135,11 @@ struct solo_p2m_dev {
 
 #define OSD_TEXT_MAX   44
 
+enum solo_enc_types {
+   SOLO_ENC_TYPE_STD,
+   SOLO_ENC_TYPE_EXT,
+};
+
 struct solo_enc_dev {
struct solo_dev *solo_dev;
/* V4L2 Items */
@@ -163,8 +168,16 @@ struct solo_enc_dev {
unsigned char   jpeg_header[1024];
int jpeg_len;
 
-   /* File handles that are listening for buffers */
-   struct list_headlisteners;
+   u32 fmt;
+   u8  enc_on;
+   enum solo_enc_types type;
+   struct videobuf_queue   vidq;
+   struct list_headvidq_active;
+   int desc_count;
+   int desc_nelts;
+   struct solo_p2m_desc*desc_items;
+   dma_addr_t  desc_dma;
+   spinlock_t  av_lock;
 };
 
 /* The SOLO6x10 PCI Device */
diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index 366f2b3..65609c1 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -41,27 +41,6 @@
 #define MP4_QS 16
 #define DMA_ALIGN  4096
 
-enum solo_enc_types {
-   SOLO_ENC_TYPE_STD,
-   SOLO_ENC_TYPE_EXT,
-};
-
-struct solo_enc_fh {
-   struct v4l2_fh  fh;
-   struct solo_enc_dev *enc;
-   u32 fmt;
-   u8  enc_on;
-   enum solo_enc_types type;
-   struct videobuf_queue   vidq;
-   struct list_headvidq_active;
-   int desc_count;
-   int desc_nelts;
-   struct solo_p2m_desc*desc_items;
-   dma_addr_t  desc_dma;
-   spinlock_t  av_lock;
-   struct list_headlist;
-};
-
 struct solo_videobuf {
struct videobuf_buffer  vb;
unsigned intflags;
@@ -286,16 +265,15 @@ static void solo_update_mode(struct solo_enc_dev 
*solo_enc)
 }
 
 /* MUST be called with solo_enc-enable_lock held */
-static int __solo_enc_on(struct solo_enc_fh *fh)
+static int __solo_enc_on(struct solo_enc_dev *solo_enc)
 {
-   struct solo_enc_dev *solo_enc = fh-enc;
u8 ch = solo_enc-ch;
struct solo_dev *solo_dev = solo_enc-solo_dev;
u8 interval;
 
BUG_ON(!mutex_is_locked(solo_enc-enable_lock));
 
-   if (fh-enc_on)
+   if (solo_enc-enc_on)
return 0;
 
solo_update_mode(solo_enc);
@@ -308,15 +286,14 @@ static int __solo_enc_on(struct solo_enc_fh *fh)
solo_dev-enc_bw_remain -= solo_enc-bw_weight;
}
 
-   fh-enc_on = 1;
-   list_add(fh-list, solo_enc-listeners);
+   solo_enc-enc_on = 1;
 
-   if (fh-type == SOLO_ENC_TYPE_EXT)
+   if (solo_enc-type == SOLO_ENC_TYPE_EXT)
solo_reg_write(solo_dev, SOLO_CAP_CH_COMP_ENA_E(ch), 1);
 
/* Reset the encoder if we are the first mpeg reader, else only reset
 * on the first mjpeg reader. */
-   if (fh-fmt == V4L2_PIX_FMT_MPEG) {
+   if (solo_enc-fmt == V4L2_PIX_FMT_MPEG) {
atomic_inc(solo_enc-readers);
if (atomic_inc_return(solo_enc-mpeg_readers)  1)
return 0;
@@ -352,32 +329,29 @@ static int __solo_enc_on(struct solo_enc_fh *fh)
return 0;
 }
 
-static int solo_enc_on(struct solo_enc_fh *fh)
+static int solo_enc_on(struct solo_enc_dev *solo_enc)
 {
-   struct solo_enc_dev *solo_enc = fh-enc;
int ret;
 
mutex_lock(solo_enc-enable_lock);
-   ret = __solo_enc_on(fh);
+   ret = __solo_enc_on(solo_enc);
mutex_unlock(solo_enc-enable_lock);
 
return ret;
 }
 
-static void __solo_enc_off(struct solo_enc_fh *fh)
+static void __solo_enc_off(struct solo_enc_dev *solo_enc)
 {
-   struct solo_enc_dev *solo_enc = fh-enc;
struct solo_dev *solo_dev = solo_enc-solo_dev;
 

Re: [RFC PATCH 5/8] s5p-fimc: Add ISP video capture driver stubs

2013-03-18 Thread Hans Verkuil
On Sun March 17 2013 22:03:38 Sylwester Nawrocki wrote:
 On 03/12/2013 03:44 PM, Hans Verkuil wrote:
  On Mon 11 March 2013 20:44:49 Sylwester Nawrocki wrote:
 [...]
  +static int isp_video_capture_open(struct file *file)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret = 0;
  +
  +  if (mutex_lock_interruptible(isp-video_lock))
  +  return -ERESTARTSYS;
  +
  +  /* ret = pm_runtime_get_sync(isp-pdev-dev); */
  +  if (ret  0)
  +  goto done;
  +
  +  ret = v4l2_fh_open(file);
  +  if (ret  0)
  +  goto done;
  +
  +  /* TODO: prepare video pipeline */
  +done:
  +  mutex_unlock(isp-video_lock);
  +  return ret;
  +}
  +
  +static int isp_video_capture_close(struct file *file)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret = 0;
  +
  +  mutex_lock(isp-video_lock);
  +
  +  if (isp-out_path == FIMC_IO_DMA) {
  +  /* TODO: stop capture, cleanup */
  +  }
  +
  +  /* pm_runtime_put(isp-pdev-dev); */
  +
  +  if (isp-ref_count == 0)
  +  vb2_queue_release(isp-capture_vb_queue);
  +
  +  ret = v4l2_fh_release(file);
  +
  +  mutex_unlock(isp-video_lock);
  +  return ret;
  +}
  +
  +static unsigned int isp_video_capture_poll(struct file *file,
  + struct poll_table_struct *wait)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret;
  +
  +  mutex_lock(isp-video_lock);
  +  ret = vb2_poll(isp-capture_vb_queue, file, wait);
  +  mutex_unlock(isp-video_lock);
  +  return ret;
  +}
  +
  +static int isp_video_capture_mmap(struct file *file, struct 
  vm_area_struct *vma)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret;
  +
  +  if (mutex_lock_interruptible(isp-video_lock))
  +  return -ERESTARTSYS;
  +
  +  ret = vb2_mmap(isp-capture_vb_queue, vma);
  +  mutex_unlock(isp-video_lock);
  +
  +  return ret;
  +}
  +
  +static const struct v4l2_file_operations isp_video_capture_fops = {
  +  .owner  = THIS_MODULE,
  +  .open   = isp_video_capture_open,
  +  .release= isp_video_capture_close,
  +  .poll   = isp_video_capture_poll,
  +  .unlocked_ioctl = video_ioctl2,
  +  .mmap   = isp_video_capture_mmap,
 
  Can't you use the helper functions vb2_fop_open/release/poll/mmap here?
 
 It seems vb2_fop_mmap/poll can be used directly, open(), release() are
 a bit more complicated as some media pipeline operations need to
 additionally be done within these callbacks. There is no vb2_fop_open(),
 and AFAICS v4l2_fh_open() is sufficient and intended as open() helper.

That's correct. Sorry for the misinformation about the non-existant
vb2_fop_open.

 For the next iteration I have used vb2_fop_release(), called indirectly,
 as it nicely simplifies things a bit.
 
 BTW, shouldn't vb2_fop_release() also be taking the lock ? Actually it is
 more useful for me in current form, but the drivers that directly assign
 it to struct v4l2_file_operations::open might be in trouble, unless I'm
 missing something.

I don't see where a lock would be needed. I don't see any concurrency here.
Nobody else can mess with the queue as long as they are not the owner.

 
  +};
  +
  +/*
  + * Video node ioctl operations
  + */
 [...]
  +static int fimc_isp_capture_streamon(struct file *file, void *priv,
  +   enum v4l2_buf_type type)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  struct v4l2_subdev *sensor = isp-pipeline.subdevs[IDX_SENSOR];
  +  struct fimc_pipeline *p =isp-pipeline;
  +  int ret;
  +
  +  /* TODO: check if the OTF interface is not running */
  +
  +  ret = media_entity_pipeline_start(sensor-entity, p-m_pipeline);
  +  if (ret  0)
  +  return ret;
  +
  +  ret = fimc_isp_pipeline_validate(isp);
  +  if (ret) {
  +  media_entity_pipeline_stop(sensor-entity);
  +  return ret;
  +  }
  +
  +  return vb2_streamon(isp-capture_vb_queue, type);
  +}
  +
  +static int fimc_isp_capture_streamoff(struct file *file, void *priv,
  +enum v4l2_buf_type type)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  struct v4l2_subdev *sd = isp-pipeline.subdevs[IDX_SENSOR];
  +  int ret;
  +
  +  ret = vb2_streamoff(isp-capture_vb_queue, type);
  +  if (ret == 0)
  +  media_entity_pipeline_stop(sd-entity);
  +  return ret;
  +}
  +
  +static int fimc_isp_capture_reqbufs(struct file *file, void *priv,
  +  struct v4l2_requestbuffers *reqbufs)
  +{
  +  struct fimc_isp *isp = video_drvdata(file);
  +  int ret;
  +
  +  reqbufs-count = max_t(u32, FIMC_IS_REQ_BUFS_MIN, reqbufs-count);
  +  ret = vb2_reqbufs(isp-capture_vb_queue, reqbufs);
 
  You probably want to call vb2_ioctl_reqbufs here since that does additional
  ownership checks that vb2_reqbufs doesn't.
 
 Yes, thanks for the suggestion. That was actually helpful, previously
 it wasn't immediately clear to me one can still take advantage of those
 vb2_ioctl_* helpers, mainly have 

Re: Fw: [patch 02/03 v2] usb hid quirks for Masterkit MA901 usb radio

2013-03-18 Thread Jiri Kosina
On Fri, 15 Mar 2013, Alexey Klimov wrote:

  indeed your patch breaks Atmega applications which using V-USB
  (http://www.obdev.at/products/vusb/index.html), because 0x16c0, 0x05df are
  the default Ids of V-USB.
 
  Have a look at this FAQ
 
  https://github.com/obdev/v-usb/blob/master/usbdrv/USB-ID-FAQ.txt
 
  It seems that the Masterkit M901 also uses V-USB.
 
  I'm using an IR remote control receiver based on Atmega8 with V-USB. Since
  Kernel 3.8.2 there is no more hidraw device for my receiver, so I had to
  change the Device-ID to 0x27d9. I think there are a lot of other V-USB
  applications with similar problems.
 
  Dirk
 
 Exactly. That's why i tried to point it out. Thanks for explaining
 this in simplier words.
 
 It's difficult to answer on top posting emails.
 
 I don't understand one thing about your letter. Did you put
 linux-media kernel list in bcc (hide copy)? Is there any reason for
 this? http://www.mail-archive.com/linux-media@vger.kernel.org/msg59714.html
 
 Mauro, Jiri,
 can we revert this patch? If you need any ack or sign from me i'm
 ready to send it.
 
 I can contact people who cares about stable trees and ask them to
 revert this patch from stable trees.
 
 During 3.9-rcX cycle i can try to figure out some fix or additional
 checks for radio-ma901.c driver.

I can revert 0322bd3980 and push it out to Linus for 3.9 still, Ccing 
stable.

Or Mauro, as the original patch went in through your tree, are you 
handling that?

Also additional work will be needed later to properly detect the 
underlying device ... the best thing to do here is to put an entry into 
hid_ignore(), similar to what we do for example for Keene FM vs. Logitech 
AudioHub.

-- 
Jiri Kosina
SUSE Labs
--
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: [REVIEW PATCH 5/5] v4l2-ioctl: simplify debug code.

2013-03-18 Thread Hans Verkuil
On Fri March 15 2013 13:25:21 Laurent Pinchart wrote:
 Hi Hans,
 
 Thanks for the patch.
 
 On Friday 15 March 2013 11:27:25 Hans Verkuil wrote:
  From: Hans Verkuil hans.verk...@cisco.com
  
  The core debug code can now be simplified since all the write-only ioctls
  are now const and will not modify the data they pass to the drivers.
  
  So instead of logging write-only ioctls before the driver is called this can
  now be done afterwards, which is cleaner when it comes to error reporting
  as well.
  
  This also fixes a logic error in the debugging code where there was one
  'else' too many.
  
  Signed-off-by: Hans Verkuil hans.verk...@cisco.com
  ---
   drivers/media/v4l2-core/v4l2-ioctl.c |   15 ++-
   1 file changed, 2 insertions(+), 13 deletions(-)
  
  diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
  b/drivers/media/v4l2-core/v4l2-ioctl.c index 2abd13a..b3fe148 100644
  --- a/drivers/media/v4l2-core/v4l2-ioctl.c
  +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
  @@ -2147,11 +2147,6 @@ static long __video_do_ioctl(struct file *file,
  }
  
  write_only = _IOC_DIR(cmd) == _IOC_WRITE;
  -   if (write_only  debug  V4L2_DEBUG_IOCTL) {
  -   v4l_printk_ioctl(video_device_node_name(vfd), cmd);
  -   pr_cont(: );
  -   info-debug(arg, write_only);
  -   }
  if (info-flags  INFO_FL_STD) {
  typedef int (*vidioc_op)(struct file *file, void *fh, void *p);
  const void *p = vfd-ioctl_ops;
  @@ -2170,16 +2165,10 @@ static long __video_do_ioctl(struct file *file,
  
   done:
  if (debug) {
  -   if (write_only  debug  V4L2_DEBUG_IOCTL) {
  -   if (ret  0)
  -   printk(KERN_DEBUG %s: error %ld\n,
  -   video_device_node_name(vfd), ret);
  -   return ret;
  -   }
  v4l_printk_ioctl(video_device_node_name(vfd), cmd);
  if (ret  0)
  -   pr_cont(: error %ld\n, ret);
  -   else if (debug == V4L2_DEBUG_IOCTL)
  +   pr_cont(: error %ld, ret);
  +   if (debug == V4L2_DEBUG_IOCTL)
 
 Shouldn't this be = V4L2_DEBUG_IOCTL ?

No. V4L2_DEBUG_IOCTL is the lowest debug level and should just print the ioctl
and return code. So the else parts are for higher debug levels where all args
are also printed.

Regards,

Hans

 
  pr_cont(\n);
  else if (_IOC_DIR(cmd) == _IOC_NONE)
  info-debug(arg, write_only);
 
 
--
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


[REVIEWv2 PATCH 0/6] v4l2: constify _IOW ioctls

2013-03-18 Thread Hans Verkuil
This is the second version of this patch series.

Two changes:

- fixed the handling of a frequency of 0 in the radio-keene driver (thanks
  to Laurent for spotting that special case)
- added a sixth patch that prevents the v4l2 core from printing more than the
  size of the buffer containing the name. The data in that buffer may not be
  0 terminated, either because that's how userspace passed the data or because
  of driver bugs. So safe-guard against that.

If nothing else comes up, then I plan on posting a pull request on Friday.

Regards,

Hans

From the first patch series:

This is the second and last phase of ensuring that the arguments of write-only
ioctls in V4L2 are const. The first phase was 4-5 months ago and added const
to s_crop, s_modulator, s_audio, s_audout, (un)subscribe_event, s_freq_hw_seek,
s_jpegcomp and s_fbuf.

This second phase adds const to s_frequency, s_tuner, s_std and s_register.
Actually, for s_std it doesn't add const but changes it to pass the std by
value which is more consistent in that particular case.

As a result drivers will be aware when they are implementing write-only ioctls
(and I saw a few drivers attempting to return data back to the user), and the
v4l2 core will know that drivers won't change the argument of a write-only
ioctls which simplifies the core debug code.

The changes have been compile-tested with the linux-media daily build but
I may have missed some more exotic architectures.

Ideally I would like to have this merged fairly early on so we have enough
time to shake out any remaining compile problems.

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


[REVIEWv2 PATCH 2/6] v4l2: add const to argument of write-only s_tuner ioctl.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This ioctl is defined as IOW, so pass the argument as const.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Acked-by: Alexey Klimov klimov.li...@gmail.com
---
 drivers/media/i2c/cx25840/cx25840-core.c |2 +-
 drivers/media/i2c/msp3400-driver.c   |2 +-
 drivers/media/i2c/saa6588.c  |2 +-
 drivers/media/i2c/saa717x.c  |2 +-
 drivers/media/i2c/tda9840.c  |2 +-
 drivers/media/i2c/tvaudio.c  |2 +-
 drivers/media/i2c/vp27smpx.c |2 +-
 drivers/media/pci/bt8xx/bttv-driver.c|   11 +++
 drivers/media/pci/cx18/cx18-av-core.c|2 +-
 drivers/media/pci/cx18/cx18-ioctl.c  |2 +-
 drivers/media/pci/cx23885/cx23885-417.c  |2 +-
 drivers/media/pci/cx23885/cx23885-video.c|2 +-
 drivers/media/pci/cx25821/cx25821-video.c|2 +-
 drivers/media/pci/cx25821/cx25821-video.h|2 +-
 drivers/media/pci/cx88/cx88-blackbird.c  |2 +-
 drivers/media/pci/cx88/cx88-video.c  |9 ++---
 drivers/media/pci/ivtv/ivtv-gpio.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/saa7164/saa7164-encoder.c  |2 +-
 drivers/media/pci/saa7164/saa7164-vbi.c  |2 +-
 drivers/media/pci/ttpci/av7110_v4l.c |2 +-
 drivers/media/radio/dsbr100.c|2 +-
 drivers/media/radio/radio-cadet.c|2 +-
 drivers/media/radio/radio-isa.c  |2 +-
 drivers/media/radio/radio-ma901.c|2 +-
 drivers/media/radio/radio-miropcm20.c|8 +---
 drivers/media/radio/radio-mr800.c|2 +-
 drivers/media/radio/radio-sf16fmi.c  |2 +-
 drivers/media/radio/radio-tea5764.c  |2 +-
 drivers/media/radio/radio-tea5777.c  |7 +++
 drivers/media/radio/radio-timb.c |2 +-
 drivers/media/radio/radio-wl1273.c   |2 +-
 drivers/media/radio/si470x/radio-si470x-common.c |2 +-
 drivers/media/radio/tef6862.c|2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c  |2 +-
 drivers/media/usb/au0828/au0828-video.c  |4 +---
 drivers/media/usb/cx231xx/cx231xx-video.c|4 ++--
 drivers/media/usb/cx231xx/cx231xx.h  |2 +-
 drivers/media/usb/em28xx/em28xx-video.c  |4 ++--
 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  |8 ++--
 drivers/media/usb/usbvision/usbvision-video.c|2 +-
 drivers/media/v4l2-core/tuner-core.c |2 +-
 drivers/staging/media/go7007/go7007-v4l2.c   |2 +-
 include/media/v4l2-ioctl.h   |2 +-
 include/media/v4l2-subdev.h  |2 +-
 sound/i2c/other/tea575x-tuner.c  |2 +-
 51 files changed, 68 insertions(+), 75 deletions(-)

diff --git a/drivers/media/i2c/cx25840/cx25840-core.c 
b/drivers/media/i2c/cx25840/cx25840-core.c
index f4339ed..234b7c6 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -1881,7 +1881,7 @@ static int cx25840_g_tuner(struct v4l2_subdev *sd, struct 
v4l2_tuner *vt)
return 0;
 }
 
-static int cx25840_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
+static int cx25840_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt)
 {
struct cx25840_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/i2c/msp3400-driver.c 
b/drivers/media/i2c/msp3400-driver.c
index 77053ba..54a9dd3 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -535,7 +535,7 @@ static int msp_g_tuner(struct v4l2_subdev *sd, struct 
v4l2_tuner *vt)
return 0;
 }
 
-static int msp_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
+static int msp_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt)
 {
struct msp_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/i2c/saa6588.c b/drivers/media/i2c/saa6588.c
index 0caac50..b4e1ccb 100644
--- a/drivers/media/i2c/saa6588.c
+++ b/drivers/media/i2c/saa6588.c
@@ -435,7 +435,7 @@ static int saa6588_g_tuner(struct v4l2_subdev *sd, struct 
v4l2_tuner *vt)
return 0;
 }
 
-static int saa6588_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
+static int 

[REVIEWv2 PATCH 4/6] v4l2: add const to argument of write-only s_register ioctl.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This ioctl is defined as IOW, so pass the argument as const.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
Acked-by: Lad, Prabhakar prabhakar.cse...@gmail.com
---
 drivers/media/dvb-frontends/au8522_decoder.c|2 +-
 drivers/media/i2c/ad9389b.c |2 +-
 drivers/media/i2c/adv7183.c |2 +-
 drivers/media/i2c/adv7604.c |2 +-
 drivers/media/i2c/ak881x.c  |2 +-
 drivers/media/i2c/cs5345.c  |2 +-
 drivers/media/i2c/cx25840/cx25840-core.c|2 +-
 drivers/media/i2c/m52790.c  |2 +-
 drivers/media/i2c/mt9m032.c |2 +-
 drivers/media/i2c/mt9v011.c |2 +-
 drivers/media/i2c/ov7670.c  |2 +-
 drivers/media/i2c/saa7115.c |2 +-
 drivers/media/i2c/saa7127.c |2 +-
 drivers/media/i2c/saa717x.c |2 +-
 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  |2 +-
 drivers/media/i2c/soc_camera/mt9v022.c  |2 +-
 drivers/media/i2c/soc_camera/ov2640.c   |2 +-
 drivers/media/i2c/soc_camera/ov5642.c   |2 +-
 drivers/media/i2c/soc_camera/ov6650.c   |2 +-
 drivers/media/i2c/soc_camera/ov772x.c   |2 +-
 drivers/media/i2c/soc_camera/ov9640.c   |2 +-
 drivers/media/i2c/soc_camera/ov9740.c   |2 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c   |2 +-
 drivers/media/i2c/soc_camera/tw9910.c   |2 +-
 drivers/media/i2c/tvp5150.c |2 +-
 drivers/media/i2c/tvp7002.c |2 +-
 drivers/media/i2c/upd64031a.c   |2 +-
 drivers/media/i2c/upd64083.c|2 +-
 drivers/media/i2c/vs6624.c  |2 +-
 drivers/media/pci/bt8xx/bttv-driver.c   |5 +--
 drivers/media/pci/cx18/cx18-av-core.c   |2 +-
 drivers/media/pci/cx18/cx18-ioctl.c |   36 +++-
 drivers/media/pci/cx23885/cx23885-ioctl.c   |9 ++--
 drivers/media/pci/cx23885/cx23885-ioctl.h   |2 +-
 drivers/media/pci/cx23885/cx23888-ir.c  |2 +-
 drivers/media/pci/cx25821/cx25821-video.c   |2 +-
 drivers/media/pci/cx25821/cx25821-video.h   |2 +-
 drivers/media/pci/cx88/cx88-video.c |2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c |   51 ---
 drivers/media/pci/saa7134/saa7134-video.c   |2 +-
 drivers/media/pci/saa7146/mxb.c |3 +-
 drivers/media/pci/saa7164/saa7164-encoder.c |2 +-
 drivers/media/platform/blackfin/bfin_capture.c  |2 +-
 drivers/media/platform/davinci/vpbe_display.c   |2 +-
 drivers/media/platform/davinci/vpif_capture.c   |3 +-
 drivers/media/platform/davinci/vpif_display.c   |3 +-
 drivers/media/platform/marvell-ccic/mcam-core.c |2 +-
 drivers/media/platform/sh_vou.c |2 +-
 drivers/media/platform/soc_camera/soc_camera.c  |2 +-
 drivers/media/usb/au0828/au0828-video.c |2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c   |2 +-
 drivers/media/usb/cx231xx/cx231xx.h |2 +-
 drivers/media/usb/em28xx/em28xx-video.c |2 +-
 drivers/media/usb/gspca/gspca.c |2 +-
 drivers/media/usb/gspca/gspca.h |8 ++--
 drivers/media/usb/gspca/pac7302.c   |2 +-
 drivers/media/usb/gspca/sn9c20x.c   |2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c |2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.h |2 +-
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c|2 +-
 drivers/media/usb/stk1160/stk1160-v4l.c |2 +-
 drivers/media/usb/usbvision/usbvision-video.c   |2 +-
 drivers/media/v4l2-core/v4l2-ioctl.c|2 +-
 include/media/v4l2-ioctl.h  |2 +-
 include/media/v4l2-subdev.h |2 +-
 68 files changed, 115 insertions(+), 123 deletions(-)

diff --git a/drivers/media/dvb-frontends/au8522_decoder.c 
b/drivers/media/dvb-frontends/au8522_decoder.c
index 5243ba6..526902b 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -583,7 +583,7 @@ static int au8522_g_register(struct v4l2_subdev *sd,
 }
 
 static int au8522_s_register(struct v4l2_subdev *sd,
-struct v4l2_dbg_register *reg)
+const struct v4l2_dbg_register *reg)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct au8522_state *state = to_state(sd);
diff --git 

[REVIEWv2 PATCH 1/6] v4l2: add const to argument of write-only s_frequency ioctl.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This ioctl is defined as IOW, so pass the argument as const.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/i2c/cx25840/cx25840-core.c |2 +-
 drivers/media/i2c/msp3400-driver.c   |2 +-
 drivers/media/i2c/tvaudio.c  |2 +-
 drivers/media/i2c/upd64031a.c|2 +-
 drivers/media/i2c/wm8775.c   |2 +-
 drivers/media/pci/bt8xx/bttv-driver.c|   14 ---
 drivers/media/pci/cx18/cx18-av-core.c|2 +-
 drivers/media/pci/cx18/cx18-ioctl.c  |2 +-
 drivers/media/pci/cx18/cx18-ioctl.h  |2 +-
 drivers/media/pci/cx23885/cx23885-417.c  |2 +-
 drivers/media/pci/cx23885/cx23885-video.c|8 ++--
 drivers/media/pci/cx23885/cx23885.h  |2 +-
 drivers/media/pci/cx25821/cx25821-video.c|4 +-
 drivers/media/pci/cx25821/cx25821-video.h|4 +-
 drivers/media/pci/cx88/cx88-blackbird.c  |2 +-
 drivers/media/pci/cx88/cx88-video.c  |   10 +++--
 drivers/media/pci/cx88/cx88.h|2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c  |2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.h  |2 +-
 drivers/media/pci/saa7134/saa7134-video.c|2 +-
 drivers/media/pci/saa7146/mxb.c  |4 +-
 drivers/media/pci/saa7164/saa7164-encoder.c  |2 +-
 drivers/media/pci/saa7164/saa7164-vbi.c  |2 +-
 drivers/media/pci/ttpci/av7110_v4l.c |2 +-
 drivers/media/radio/dsbr100.c|2 +-
 drivers/media/radio/radio-cadet.c|   46 +++---
 drivers/media/radio/radio-isa.c  |9 +++--
 drivers/media/radio/radio-keene.c|   13 +++---
 drivers/media/radio/radio-ma901.c|2 +-
 drivers/media/radio/radio-miropcm20.c|4 +-
 drivers/media/radio/radio-mr800.c|2 +-
 drivers/media/radio/radio-sf16fmi.c  |2 +-
 drivers/media/radio/radio-si4713.c   |2 +-
 drivers/media/radio/radio-tea5764.c  |2 +-
 drivers/media/radio/radio-tea5777.c  |2 +-
 drivers/media/radio/radio-timb.c |2 +-
 drivers/media/radio/radio-wl1273.c   |2 +-
 drivers/media/radio/si470x/radio-si470x-common.c |2 +-
 drivers/media/radio/si4713-i2c.c |5 +--
 drivers/media/radio/tef6862.c|2 +-
 drivers/media/radio/wl128x/fmdrv_v4l2.c  |6 +--
 drivers/media/usb/au0828/au0828-video.c  |2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c|7 ++--
 drivers/media/usb/cx231xx/cx231xx.h  |2 +-
 drivers/media/usb/em28xx/em28xx-video.c  |7 ++--
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c |2 +-
 drivers/media/usb/tlg2300/pd-radio.c |2 +-
 drivers/media/usb/tlg2300/pd-video.c |5 ++-
 drivers/media/usb/tm6000/tm6000-video.c  |2 +-
 drivers/media/usb/usbvision/usbvision-video.c|2 +-
 drivers/media/v4l2-core/tuner-core.c |2 +-
 drivers/media/v4l2-core/v4l2-ioctl.c |2 +-
 drivers/staging/media/go7007/go7007-v4l2.c   |2 +-
 include/media/v4l2-ioctl.h   |2 +-
 include/media/v4l2-subdev.h  |2 +-
 sound/i2c/other/tea575x-tuner.c  |4 +-
 56 files changed, 119 insertions(+), 111 deletions(-)

diff --git a/drivers/media/i2c/cx25840/cx25840-core.c 
b/drivers/media/i2c/cx25840/cx25840-core.c
index f4149eb..f4339ed 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -1835,7 +1835,7 @@ static int cx25840_s_audio_routing(struct v4l2_subdev *sd,
return set_input(client, state-vid_input, input);
 }
 
-static int cx25840_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency 
*freq)
+static int cx25840_s_frequency(struct v4l2_subdev *sd, const struct 
v4l2_frequency *freq)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
 
diff --git a/drivers/media/i2c/msp3400-driver.c 
b/drivers/media/i2c/msp3400-driver.c
index 766305f..77053ba 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -445,7 +445,7 @@ static int msp_s_radio(struct v4l2_subdev *sd)
return 0;
 }
 
-static int msp_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
+static int msp_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequency 
*freq)
 {
struct i2c_client *client = v4l2_get_subdevdata(sd);
 
diff --git a/drivers/media/i2c/tvaudio.c b/drivers/media/i2c/tvaudio.c
index 4c91b35..4b12c51 100644
--- a/drivers/media/i2c/tvaudio.c
+++ b/drivers/media/i2c/tvaudio.c
@@ -1817,7 +1817,7 @@ static int tvaudio_s_std(struct v4l2_subdev *sd, 

[REVIEWv2 PATCH 5/6] v4l2-ioctl: simplify debug code.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The core debug code can now be simplified since all the write-only ioctls are
now const and will not modify the data they pass to the drivers.

So instead of logging write-only ioctls before the driver is called this can
now be done afterwards, which is cleaner when it comes to error reporting as
well.

This also fixes a logic error in the debugging code where there was one 'else'
too many.

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

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 2abd13a..b3fe148 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2147,11 +2147,6 @@ static long __video_do_ioctl(struct file *file,
}
 
write_only = _IOC_DIR(cmd) == _IOC_WRITE;
-   if (write_only  debug  V4L2_DEBUG_IOCTL) {
-   v4l_printk_ioctl(video_device_node_name(vfd), cmd);
-   pr_cont(: );
-   info-debug(arg, write_only);
-   }
if (info-flags  INFO_FL_STD) {
typedef int (*vidioc_op)(struct file *file, void *fh, void *p);
const void *p = vfd-ioctl_ops;
@@ -2170,16 +2165,10 @@ static long __video_do_ioctl(struct file *file,
 
 done:
if (debug) {
-   if (write_only  debug  V4L2_DEBUG_IOCTL) {
-   if (ret  0)
-   printk(KERN_DEBUG %s: error %ld\n,
-   video_device_node_name(vfd), ret);
-   return ret;
-   }
v4l_printk_ioctl(video_device_node_name(vfd), cmd);
if (ret  0)
-   pr_cont(: error %ld\n, ret);
-   else if (debug == V4L2_DEBUG_IOCTL)
+   pr_cont(: error %ld, ret);
+   if (debug == V4L2_DEBUG_IOCTL)
pr_cont(\n);
else if (_IOC_DIR(cmd) == _IOC_NONE)
info-debug(arg, write_only);
-- 
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


[REVIEWv2 PATCH 6/6] v4l2-ioctl: add precision when printing names.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Never print more than the size of the buffer containing the name.

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

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index b3fe148..168b51e 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -167,9 +167,11 @@ static void v4l_print_querycap(const void *arg, bool 
write_only)
 {
const struct v4l2_capability *p = arg;
 
-   pr_cont(driver=%s, card=%s, bus=%s, version=0x%08x, 
+   pr_cont(driver=%.*s, card=%.*s, bus=%.*s, version=0x%08x, 
capabilities=0x%08x, device_caps=0x%08x\n,
-   p-driver, p-card, p-bus_info,
+   (int)sizeof(p-driver), p-driver,
+   (int)sizeof(p-card), p-card,
+   (int)sizeof(p-bus_info), p-bus_info,
p-version, p-capabilities, p-device_caps);
 }
 
@@ -177,20 +179,21 @@ static void v4l_print_enuminput(const void *arg, bool 
write_only)
 {
const struct v4l2_input *p = arg;
 
-   pr_cont(index=%u, name=%s, type=%u, audioset=0x%x, tuner=%u, 
+   pr_cont(index=%u, name=%.*s, type=%u, audioset=0x%x, tuner=%u, 
std=0x%08Lx, status=0x%x, capabilities=0x%x\n,
-   p-index, p-name, p-type, p-audioset, p-tuner,
-   (unsigned long long)p-std, p-status, p-capabilities);
+   p-index, (int)sizeof(p-name), p-name, p-type, p-audioset,
+   p-tuner, (unsigned long long)p-std, p-status,
+   p-capabilities);
 }
 
 static void v4l_print_enumoutput(const void *arg, bool write_only)
 {
const struct v4l2_output *p = arg;
 
-   pr_cont(index=%u, name=%s, type=%u, audioset=0x%x, 
+   pr_cont(index=%u, name=%.*s, type=%u, audioset=0x%x, 
modulator=%u, std=0x%08Lx, capabilities=0x%x\n,
-   p-index, p-name, p-type, p-audioset, p-modulator,
-   (unsigned long long)p-std, p-capabilities);
+   p-index, (int)sizeof(p-name), p-name, p-type, p-audioset,
+   p-modulator, (unsigned long long)p-std, p-capabilities);
 }
 
 static void v4l_print_audio(const void *arg, bool write_only)
@@ -200,8 +203,9 @@ static void v4l_print_audio(const void *arg, bool 
write_only)
if (write_only)
pr_cont(index=%u, mode=0x%x\n, p-index, p-mode);
else
-   pr_cont(index=%u, name=%s, capability=0x%x, mode=0x%x\n,
-   p-index, p-name, p-capability, p-mode);
+   pr_cont(index=%u, name=%.*s, capability=0x%x, mode=0x%x\n,
+   p-index, (int)sizeof(p-name), p-name,
+   p-capability, p-mode);
 }
 
 static void v4l_print_audioout(const void *arg, bool write_only)
@@ -211,21 +215,22 @@ static void v4l_print_audioout(const void *arg, bool 
write_only)
if (write_only)
pr_cont(index=%u\n, p-index);
else
-   pr_cont(index=%u, name=%s, capability=0x%x, mode=0x%x\n,
-   p-index, p-name, p-capability, p-mode);
+   pr_cont(index=%u, name=%.*s, capability=0x%x, mode=0x%x\n,
+   p-index, (int)sizeof(p-name), p-name,
+   p-capability, p-mode);
 }
 
 static void v4l_print_fmtdesc(const void *arg, bool write_only)
 {
const struct v4l2_fmtdesc *p = arg;
 
-   pr_cont(index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, 
description='%s'\n,
+   pr_cont(index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, 
description='%.*s'\n,
p-index, prt_names(p-type, v4l2_type_names),
p-flags, (p-pixelformat  0xff),
(p-pixelformat   8)  0xff,
(p-pixelformat  16)  0xff,
(p-pixelformat  24)  0xff,
-   p-description);
+   (int)sizeof(p-description), p-description);
 }
 
 static void v4l_print_format(const void *arg, bool write_only)
@@ -348,9 +353,9 @@ static void v4l_print_modulator(const void *arg, bool 
write_only)
if (write_only)
pr_cont(index=%u, txsubchans=0x%x, p-index, p-txsubchans);
else
-   pr_cont(index=%u, name=%s, capability=0x%x, 
+   pr_cont(index=%u, name=%.*s, capability=0x%x, 
rangelow=%u, rangehigh=%u, txsubchans=0x%x\n,
-   p-index, p-name, p-capability,
+   p-index, (int)sizeof(p-name), p-name, p-capability,
p-rangelow, p-rangehigh, p-txsubchans);
 }
 
@@ -361,10 +366,10 @@ static void v4l_print_tuner(const void *arg, bool 
write_only)
if (write_only)
pr_cont(index=%u, audmode=%u\n, p-index, p-audmode);
else
-   pr_cont(index=%u, name=%s, type=%u, capability=0x%x, 

[REVIEWv2 PATCH 3/6] v4l2: pass std by value to the write-only s_std ioctl.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This ioctl is defined as IOW, so pass the argument by value instead of by
reference. I could have chosen to add const instead, but this is 1) easier
to handle in drivers and 2) consistent with the s_std subdev operation.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Acked-by: Jonathan Corbet cor...@lwn.net
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
Acked-by: Lad, Prabhakar prabhakar.cse...@gmail.com
---
 drivers/media/common/saa7146/saa7146_video.c|4 ++--
 drivers/media/parport/pms.c |4 ++--
 drivers/media/pci/bt8xx/bttv-driver.c   |6 +++---
 drivers/media/pci/cx18/cx18-driver.c|2 +-
 drivers/media/pci/cx18/cx18-ioctl.c |   10 +-
 drivers/media/pci/cx18/cx18-ioctl.h |2 +-
 drivers/media/pci/cx23885/cx23885-417.c |6 +++---
 drivers/media/pci/cx23885/cx23885-video.c   |4 ++--
 drivers/media/pci/cx25821/cx25821-video.c   |6 +++---
 drivers/media/pci/cx25821/cx25821-video.h   |2 +-
 drivers/media/pci/cx88/cx88-blackbird.c |4 ++--
 drivers/media/pci/cx88/cx88-video.c |4 ++--
 drivers/media/pci/ivtv/ivtv-driver.c|4 ++--
 drivers/media/pci/ivtv/ivtv-firmware.c  |4 ++--
 drivers/media/pci/ivtv/ivtv-ioctl.c |   18 +-
 drivers/media/pci/ivtv/ivtv-ioctl.h |4 ++--
 drivers/media/pci/saa7134/saa7134-empress.c |2 +-
 drivers/media/pci/saa7134/saa7134-video.c   |   14 +++---
 drivers/media/pci/saa7134/saa7134.h |2 +-
 drivers/media/pci/saa7164/saa7164-encoder.c |8 
 drivers/media/pci/saa7164/saa7164-vbi.c |8 
 drivers/media/pci/sta2x11/sta2x11_vip.c |   18 +-
 drivers/media/pci/zoran/zoran_driver.c  |4 ++--
 drivers/media/platform/blackfin/bfin_capture.c  |6 +++---
 drivers/media/platform/davinci/vpbe.c   |8 
 drivers/media/platform/davinci/vpbe_display.c   |2 +-
 drivers/media/platform/davinci/vpfe_capture.c   |   12 ++--
 drivers/media/platform/davinci/vpif_capture.c   |6 +++---
 drivers/media/platform/davinci/vpif_display.c   |   10 +-
 drivers/media/platform/fsl-viu.c|6 +++---
 drivers/media/platform/marvell-ccic/mcam-core.c |2 +-
 drivers/media/platform/s5p-tv/mixer_video.c |4 ++--
 drivers/media/platform/sh_vou.c |   12 ++--
 drivers/media/platform/soc_camera/soc_camera.c  |4 ++--
 drivers/media/platform/timblogiw.c  |6 +++---
 drivers/media/platform/via-camera.c |2 +-
 drivers/media/platform/vino.c   |   10 +-
 drivers/media/usb/au0828/au0828-video.c |4 ++--
 drivers/media/usb/cx231xx/cx231xx-417.c |4 ++--
 drivers/media/usb/cx231xx/cx231xx-video.c   |6 +++---
 drivers/media/usb/em28xx/em28xx-video.c |8 
 drivers/media/usb/hdpvr/hdpvr-video.c   |4 ++--
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c|4 ++--
 drivers/media/usb/s2255/s2255drv.c  |8 
 drivers/media/usb/stk1160/stk1160-v4l.c |4 ++--
 drivers/media/usb/tlg2300/pd-video.c|8 
 drivers/media/usb/tm6000/tm6000-video.c |6 +++---
 drivers/media/usb/usbvision/usbvision-video.c   |4 ++--
 drivers/media/v4l2-core/v4l2-ioctl.c|6 +++---
 drivers/staging/media/davinci_vpfe/vpfe_video.c |6 +++---
 drivers/staging/media/dt3155v4l/dt3155v4l.c |4 ++--
 drivers/staging/media/go7007/go7007-v4l2.c  |   16 
 drivers/staging/media/solo6x10/v4l2-enc.c   |2 +-
 drivers/staging/media/solo6x10/v4l2.c   |2 +-
 include/media/davinci/vpbe.h|2 +-
 include/media/v4l2-ioctl.h  |2 +-
 56 files changed, 165 insertions(+), 165 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_video.c 
b/drivers/media/common/saa7146/saa7146_video.c
index 4143d61..fe907f2 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -832,7 +832,7 @@ static int vidioc_g_std(struct file *file, void *fh, 
v4l2_std_id *norm)
}
*/
 
-static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id)
+static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id id)
 {
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)-dev;
struct saa7146_vv *vv = dev-vv_data;
@@ -856,7 +856,7 @@ static int vidioc_s_std(struct file *file, void *fh, 
v4l2_std_id *id)
}
 
for (i = 0; i  dev-ext_vv_data-num_stds; i++)
-   if (*id  dev-ext_vv_data-stds[i].id)
+   if (id  dev-ext_vv_data-stds[i].id)
   

Re: [REVIEW PATCH 0/6] s5p-tv: replace dv_preset by dv_timings

2013-03-18 Thread Hans Verkuil
On Mon March 4 2013 14:02:00 Hans Verkuil wrote:
 Hi Tomasz,
 
 Here is what I hope is the final patch series for this. I've incorporated
 your suggestions and it's split off from the davinci/blackfin changes into
 its own patch series to keep things better organized.
 
 The changes since the previous version are:
 
 - changed the order of the first three patches as per your suggestion.
 - the patch named [RFC PATCH 08/18] s5p-tv: add dv_timings support for
   mixer_video. had two changes that rightfully belonged to the 'add
   dv_timings support for mixer_video.' patch. Moved them accordingly.
 - hdmiphy now also supports dv_timings_cap and sets the pixelclock range
   accordingly. The hdmi driver chains hdmiphy to get those values.
 - updating the minimum width to 720.
 
 I didn't add a comment to clarify the pixclk handling hdmiphy_s_dv_preset
 because 1) I forgot, 2) it's not a bug, and 3) that whole function is
 removed anyway a few patches later :-)
 
 The only functional change is the handling of dv_timings_cap. Can you
 verify that that works as it should?

Tomasz,

Should I wait for feedback from you, or can I go ahead and make a pull
request for this?

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


[RFC PATCH 0/6] Add VIDIOC_DBG_G_CHIP_NAME ioctl.

2013-03-18 Thread Hans Verkuil
This is a patch series implementing this proposal:

http://comments.gmane.org/gmane.linux.drivers.video-input-infrastructure/61539

It keeps the old CHIP_IDENT around for now. My plan is to start removing
support for VIDIOC_G_CHIP_IDENT and the match types V4L2_CHIP_MATCH_I2C_DRIVER,
V4L2_CHIP_MATCH_I2C_ADDR and V4L2_CHIP_MATCH_AC97 for 3.11. Once it's all
removed we can also ditch the v4l2-chip-ident.h header.

These debugging ioctls have always been a bit problematic, but sub-devices
are a much better fit and greatly simplify the implementation.

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


[RFC PATCH 2/6] v4l2: add new VIDIOC_DBG_G_CHIP_NAME ioctl.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Simplify the debugging ioctls by creating the VIDIOC_DBG_G_CHIP_NAME ioctl.
This will eventually replace VIDIOC_DBG_G_CHIP_IDENT. Chip matching is done
by the name or index of subdevices or an index to a bridge chip. Most of this
can all be done automatically, so most drivers just need to provide get/set
register ops.

In particular, it is now possible to get/set subdev registers without
requiring assistance of the bridge driver.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-common.c |5 +-
 drivers/media/v4l2-core/v4l2-dev.c|5 +-
 drivers/media/v4l2-core/v4l2-ioctl.c  |  115 +++--
 include/media/v4l2-ioctl.h|3 +
 include/uapi/linux/videodev2.h|   34 +++---
 5 files changed, 146 insertions(+), 16 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-common.c 
b/drivers/media/v4l2-core/v4l2-common.c
index 46d2b9b..537be23 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -230,7 +230,7 @@ EXPORT_SYMBOL(v4l2_ctrl_next);
 int v4l2_chip_match_host(const struct v4l2_dbg_match *match)
 {
switch (match-type) {
-   case V4L2_CHIP_MATCH_HOST:
+   case V4L2_CHIP_MATCH_BRIDGE:
return match-addr == 0;
default:
return 0;
@@ -254,6 +254,9 @@ int v4l2_chip_match_i2c_client(struct i2c_client *c, const 
struct v4l2_dbg_match
return len  !strncmp(c-driver-driver.name, match-name, 
len);
case V4L2_CHIP_MATCH_I2C_ADDR:
return c-addr == match-addr;
+   case V4L2_CHIP_MATCH_SUBDEV_IDX:
+   case V4L2_CHIP_MATCH_SUBDEV_NAME:
+   return 1;
default:
return 0;
}
diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index de1e9ab..c0c651d 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -591,9 +591,10 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
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);
+   set_bit(_IOC_NR(VIDIOC_DBG_G_CHIP_NAME), valid_ioctls);
 #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);
+   set_bit(_IOC_NR(VIDIOC_DBG_G_REGISTER), valid_ioctls);
+   set_bit(_IOC_NR(VIDIOC_DBG_S_REGISTER), valid_ioctls);
 #endif
SET_VALID_IOCTL(ops, VIDIOC_DBG_G_CHIP_IDENT, vidioc_g_chip_ident);
/* yes, really vidioc_subscribe_event */
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index aa6e7c7..923ec95 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -622,7 +622,8 @@ static void v4l_print_dbg_chip_ident(const void *arg, bool 
write_only)
const struct v4l2_dbg_chip_ident *p = arg;
 
pr_cont(type=%u, , p-match.type);
-   if (p-match.type == V4L2_CHIP_MATCH_I2C_DRIVER)
+   if (p-match.type == V4L2_CHIP_MATCH_I2C_DRIVER ||
+   p-match.type == V4L2_CHIP_MATCH_SUBDEV_NAME)
pr_cont(name=%s, , p-match.name);
else
pr_cont(addr=%u, , p-match.addr);
@@ -630,12 +631,27 @@ static void v4l_print_dbg_chip_ident(const void *arg, 
bool write_only)
p-ident, p-revision);
 }
 
+static void v4l_print_dbg_chip_name(const void *arg, bool write_only)
+{
+   const struct v4l2_dbg_chip_name *p = arg;
+
+   pr_cont(type=%u, , p-match.type);
+   if (p-match.type == V4L2_CHIP_MATCH_I2C_DRIVER ||
+   p-match.type == V4L2_CHIP_MATCH_SUBDEV_NAME)
+   pr_cont(name=%.*s, ,
+   (int)sizeof(p-match.name), p-match.name);
+   else
+   pr_cont(addr=%u, , p-match.addr);
+   pr_cont(name=%.*s\n, (int)sizeof(p-name), p-name);
+}
+
 static void v4l_print_dbg_register(const void *arg, bool write_only)
 {
const struct v4l2_dbg_register *p = arg;
 
pr_cont(type=%u, , p-match.type);
-   if (p-match.type == V4L2_CHIP_MATCH_I2C_DRIVER)
+   if (p-match.type == V4L2_CHIP_MATCH_I2C_DRIVER ||
+   p-match.type == V4L2_CHIP_MATCH_SUBDEV_NAME)
pr_cont(name=%s, , p-match.name);
else
pr_cont(addr=%u, , p-match.addr);
@@ -1787,15 +1803,38 @@ static int v4l_log_status(const struct v4l2_ioctl_ops 
*ops,
return ret;
 }
 
+static bool v4l_dbg_found_match(const struct v4l2_dbg_match *match,
+   struct v4l2_subdev *sd, int idx)
+{
+   if (match-type == V4L2_CHIP_MATCH_SUBDEV_IDX)
+   return match-addr == idx;
+   return !strcmp(match-name, sd-name);
+}
+
 static int 

[RFC PATCH 1/6] v4l2-common: remove obsolete check for ' at the end of a driver name.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

During the transition to sub-devices several years ago non-subdev drivers
had a ' at the end of their driver name to tell them apart from already
converted drivers. This check was a left-over from that time and can be
removed.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-common.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-common.c 
b/drivers/media/v4l2-core/v4l2-common.c
index aa044f4..46d2b9b 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -251,9 +251,6 @@ int v4l2_chip_match_i2c_client(struct i2c_client *c, const 
struct v4l2_dbg_match
if (c-driver == NULL || c-driver-driver.name == NULL)
return 0;
len = strlen(c-driver-driver.name);
-   /* legacy drivers have a ' suffix, don't try to match that */
-   if (len  c-driver-driver.name[len - 1] == '\'')
-   len--;
return len  !strncmp(c-driver-driver.name, match-name, 
len);
case V4L2_CHIP_MATCH_I2C_ADDR:
return c-addr == match-addr;
-- 
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


[RFC PATCH 4/6] em28xx: add support for g_chip_name.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add support for vidioc_g_chip_name, allowing AC97 to be implemented as a
second chip on the bridge with the name ac97. v4l2-dbg can just match the
name with that string in order to detect a ac97-compliant set of registers.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/em28xx/em28xx-video.c |   41 +--
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 93fc620..99fcd50 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1242,9 +1242,9 @@ static int vidioc_g_chip_ident(struct file *file, void 
*priv,
 
chip-ident = V4L2_IDENT_NONE;
chip-revision = 0;
-   if (chip-match.type == V4L2_CHIP_MATCH_HOST) {
-   if (v4l2_chip_match_host(chip-match))
-   chip-ident = V4L2_IDENT_NONE;
+   if (chip-match.type == V4L2_CHIP_MATCH_BRIDGE) {
+   if (chip-match.addr  1)
+   return -EINVAL;
return 0;
}
if (chip-match.type != V4L2_CHIP_MATCH_I2C_DRIVER 
@@ -1256,6 +1256,21 @@ static int vidioc_g_chip_ident(struct file *file, void 
*priv,
return 0;
 }
 
+static int vidioc_g_chip_name(struct file *file, void *priv,
+  struct v4l2_dbg_chip_name *chip)
+{
+   struct em28xx_fh  *fh  = priv;
+   struct em28xx *dev = fh-dev;
+
+   if (chip-match.addr  1)
+   return -EINVAL;
+   if (chip-match.addr == 1)
+   strlcpy(chip-name, ac97, sizeof(chip-name));
+   else
+   strlcpy(chip-name, dev-v4l2_dev.name, sizeof(chip-name));
+   return 0;
+}
+
 #ifdef CONFIG_VIDEO_ADV_DEBUG
 static int em28xx_reg_len(int reg)
 {
@@ -1277,6 +1292,12 @@ static int vidioc_g_register(struct file *file, void 
*priv,
int ret;
 
switch (reg-match.type) {
+   case V4L2_CHIP_MATCH_BRIDGE:
+   if (reg-match.addr  1)
+   return -EINVAL;
+   if (!reg-match.addr)
+   break;
+   /* fall-through */
case V4L2_CHIP_MATCH_AC97:
ret = em28xx_read_ac97(dev, reg-reg);
if (ret  0)
@@ -1293,8 +1314,7 @@ static int vidioc_g_register(struct file *file, void 
*priv,
v4l2_device_call_all(dev-v4l2_dev, 0, core, g_register, reg);
return 0;
default:
-   if (!v4l2_chip_match_host(reg-match))
-   return -EINVAL;
+   return -EINVAL;
}
 
/* Match host */
@@ -1327,6 +1347,12 @@ static int vidioc_s_register(struct file *file, void 
*priv,
__le16 buf;
 
switch (reg-match.type) {
+   case V4L2_CHIP_MATCH_BRIDGE:
+   if (reg-match.addr  1)
+   return -EINVAL;
+   if (!reg-match.addr)
+   break;
+   /* fall-through */
case V4L2_CHIP_MATCH_AC97:
return em28xx_write_ac97(dev, reg-reg, reg-val);
case V4L2_CHIP_MATCH_I2C_DRIVER:
@@ -1337,8 +1363,7 @@ static int vidioc_s_register(struct file *file, void 
*priv,
v4l2_device_call_all(dev-v4l2_dev, 0, core, s_register, reg);
return 0;
default:
-   if (!v4l2_chip_match_host(reg-match))
-   return -EINVAL;
+   return -EINVAL;
}
 
/* Match host */
@@ -1696,6 +1721,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
.vidioc_g_chip_ident= vidioc_g_chip_ident,
+   .vidioc_g_chip_name = vidioc_g_chip_name,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register  = vidioc_g_register,
.vidioc_s_register  = vidioc_s_register,
@@ -1726,6 +1752,7 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
.vidioc_g_chip_ident  = vidioc_g_chip_ident,
+   .vidioc_g_chip_name   = vidioc_g_chip_name,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register= vidioc_g_register,
.vidioc_s_register= vidioc_s_register,
-- 
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


[RFC PATCH 5/6] DocBook media: fix syntax problems in dvbproperty.xml

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Caught by xmllint.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/dvb/dvbproperty.xml |   46 +++
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/Documentation/DocBook/media/dvb/dvbproperty.xml 
b/Documentation/DocBook/media/dvb/dvbproperty.xml
index 4a5eaee..341b3f0 100644
--- a/Documentation/DocBook/media/dvb/dvbproperty.xml
+++ b/Documentation/DocBook/media/dvb/dvbproperty.xml
@@ -903,14 +903,12 @@ enum fe_interleaving {
constantsvalue/constant is for signed values of the 
measure (dB measures)
and constantuvalue/constant is for unsigned values 
(counters, relative scale)/para/listitem
listitemparaconstantscale/constant - Scale for the 
value. It can be:/para
-   section id = fecap-scale-params
-   itemizedlist mark='bullet'
+   itemizedlist mark='bullet' id=fecap-scale-params

listitemparaconstantFE_SCALE_NOT_AVAILABLE/constant - The parameter is 
supported by the frontend, but it was not possible to collect it (could be a 
transitory or permanent condition)/para/listitem

listitemparaconstantFE_SCALE_DECIBEL/constant - parameter is a signed 
value, measured in 1/1000 dB/para/listitem

listitemparaconstantFE_SCALE_RELATIVE/constant - parameter is a 
unsigned value, where 0 means 0% and 65535 means 100%./para/listitem

listitemparaconstantFE_SCALE_COUNTER/constant - parameter is a unsigned 
value that counts the occurrence of an event, like bit error, block error, or 
lapsed time./para/listitem
/itemizedlist
-   /section
/listitem
/itemizedlist
section id=DTV-STAT-SIGNAL-STRENGTH
@@ -918,9 +916,9 @@ enum fe_interleaving {
paraIndicates the signal strength level at the analog part of 
the tuner or of the demod./para
paraPossible scales for this metric are:/para
itemizedlist mark='bullet'
-   listitemconstantFE_SCALE_NOT_AVAILABLE/constant - 
it failed to measure it, or the measurement was not complete yet./listitem
-   listitemconstantFE_SCALE_DECIBEL/constant - 
signal strength is in 0.0001 dBm units, power measured in miliwatts. This value 
is generally negative./listitem
-   listitemconstantFE_SCALE_RELATIVE/constant - The 
frontend provides a 0% to 100% measurement for power (actually, 0 to 
65535)./listitem
+   
listitemparaconstantFE_SCALE_NOT_AVAILABLE/constant - it failed to 
measure it, or the measurement was not complete yet./para/listitem
+   listitemparaconstantFE_SCALE_DECIBEL/constant - 
signal strength is in 0.0001 dBm units, power measured in miliwatts. This value 
is generally negative./para/listitem
+   listitemparaconstantFE_SCALE_RELATIVE/constant 
- The frontend provides a 0% to 100% measurement for power (actually, 0 to 
65535)./para/listitem
/itemizedlist
/section
section id=DTV-STAT-CNR
@@ -928,9 +926,9 @@ enum fe_interleaving {
paraIndicates the Signal to Noise ratio for the main 
carrier./para
paraPossible scales for this metric are:/para
itemizedlist mark='bullet'
-   listitemconstantFE_SCALE_NOT_AVAILABLE/constant - 
it failed to measure it, or the measurement was not complete yet./listitem
-   listitemconstantFE_SCALE_DECIBEL/constant - 
Signal/Noise ratio is in 0.0001 dB units./listitem
-   listitemconstantFE_SCALE_RELATIVE/constant - The 
frontend provides a 0% to 100% measurement for Signal/Noise (actually, 0 to 
65535)./listitem
+   
listitemparaconstantFE_SCALE_NOT_AVAILABLE/constant - it failed to 
measure it, or the measurement was not complete yet./para/listitem
+   listitemparaconstantFE_SCALE_DECIBEL/constant - 
Signal/Noise ratio is in 0.0001 dB units./para/listitem
+   listitemparaconstantFE_SCALE_RELATIVE/constant 
- The frontend provides a 0% to 100% measurement for Signal/Noise (actually, 0 
to 65535)./para/listitem
/itemizedlist
/section
section id=DTV-STAT-PRE-ERROR-BIT-COUNT
@@ -943,8 +941,8 @@ enum fe_interleaving {
  The frontend may reset it when a channel/transponder is 
tuned./para
paraPossible scales for this metric are:/para
itemizedlist mark='bullet'
-   listitemconstantFE_SCALE_NOT_AVAILABLE/constant - 
it failed to measure it, or the measurement was not complete yet./listitem
-   listitemconstantFE_SCALE_COUNTER/constant - 

[RFC PATCH 3/6] stk1160: remove V4L2_CHIP_MATCH_AC97 placeholder.

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

It was just a placeholder and we want to get rid of the AC97 matching
define.

Also replace MATCH_HOST with MATCH_BRIDGE since we are here anyway.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/stk1160/stk1160-v4l.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c 
b/drivers/media/usb/stk1160/stk1160-v4l.c
index 5307a63..ef0ca2d 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -458,7 +458,7 @@ static int vidioc_g_chip_ident(struct file *file, void 
*priv,
   struct v4l2_dbg_chip_ident *chip)
 {
switch (chip-match.type) {
-   case V4L2_CHIP_MATCH_HOST:
+   case V4L2_CHIP_MATCH_BRIDGE:
chip-ident = V4L2_IDENT_NONE;
chip-revision = 0;
return 0;
@@ -476,9 +476,6 @@ static int vidioc_g_register(struct file *file, void *priv,
u8 val;
 
switch (reg-match.type) {
-   case V4L2_CHIP_MATCH_AC97:
-   /* TODO: Support me please :-( */
-   return -EINVAL;
case V4L2_CHIP_MATCH_I2C_DRIVER:
v4l2_device_call_all(dev-v4l2_dev, 0, core, g_register, reg);
return 0;
@@ -505,8 +502,6 @@ static int vidioc_s_register(struct file *file, void *priv,
struct stk1160 *dev = video_drvdata(file);
 
switch (reg-match.type) {
-   case V4L2_CHIP_MATCH_AC97:
-   return -EINVAL;
case V4L2_CHIP_MATCH_I2C_DRIVER:
v4l2_device_call_all(dev-v4l2_dev, 0, core, s_register, reg);
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


[RFC PATCH 6/6] DocBook media: add VIDIOC_DBG_G_CHIP_NAME documentation

2013-03-18 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

And update the other debug ioctls accordingly.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/v4l2.xml   |4 +-
 .../DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml  |   14 +-
 .../DocBook/media/v4l/vidioc-dbg-g-chip-name.xml   |  234 
 .../DocBook/media/v4l/vidioc-dbg-g-register.xml|   42 +++-
 4 files changed, 280 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml

diff --git a/Documentation/DocBook/media/v4l/v4l2.xml 
b/Documentation/DocBook/media/v4l/v4l2.xml
index a3cce18..a3c7adb7 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -144,8 +144,7 @@ applications. --
date2012-12-03/date
authorinitialssa, sn/authorinitials
revremarkAdded timestamp types to v4l2_buffer.
-   Added constantV4L2_EVENT_CTRL_CH_RANGE/constant control
-   event changes flag, see xref linkend=changes-flags/.
+   Added V4L2_EVENT_CTRL_CH_RANGE control event changes flag.
/revremark
   /revision
 
@@ -537,6 +536,7 @@ and discussions on the V4L mailing list./revremark
 sub-create-bufs;
 sub-cropcap;
 sub-dbg-g-chip-ident;
+sub-dbg-g-chip-name;
 sub-dbg-g-register;
 sub-decoder-cmd;
 sub-dqevent;
diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml 
b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml
index 4ecd966..82e43c6 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml
@@ -200,10 +200,10 @@ the values from xref linkend=chip-ids /./entry
cs-def;
tbody valign=top
  row
-   entryconstantV4L2_CHIP_MATCH_HOST/constant/entry
+   entryconstantV4L2_CHIP_MATCH_BRIDGE/constant/entry
entry0/entry
entryMatch the nth chip on the card, zero for the
-   host chip. Does not match i2c; chips./entry
+   bridge chip. Does not match sub-devices./entry
  /row
  row
entryconstantV4L2_CHIP_MATCH_I2C_DRIVER/constant/entry
@@ -220,6 +220,16 @@ the values from xref linkend=chip-ids /./entry
entry3/entry
entryMatch the nth anciliary AC97 chip./entry
  /row
+ row
+   entryconstantV4L2_CHIP_MATCH_SUBDEV_NAME/constant/entry
+   entry4/entry
+   entryMatch the sub-device by name. Can't be used with this 
ioctl./entry
+ /row
+ row
+   entryconstantV4L2_CHIP_MATCH_SUBDEV_IDX/constant/entry
+   entry5/entry
+   entryMatch the nth sub-device. Can't be used with this 
ioctl./entry
+ /row
/tbody
   /tgroup
 /table
diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml 
b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml
new file mode 100644
index 000..4921346
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml
@@ -0,0 +1,234 @@
+refentry id=vidioc-dbg-g-chip-name
+  refmeta
+refentrytitleioctl VIDIOC_DBG_G_CHIP_NAME/refentrytitle
+manvol;
+  /refmeta
+
+  refnamediv
+refnameVIDIOC_DBG_G_CHIP_NAME/refname
+refpurposeIdentify the chips on a TV card/refpurpose
+  /refnamediv
+
+  refsynopsisdiv
+funcsynopsis
+  funcprototype
+   funcdefint functionioctl/function/funcdef
+   paramdefint parameterfd/parameter/paramdef
+   paramdefint parameterrequest/parameter/paramdef
+   paramdefstruct v4l2_dbg_chip_name
+*parameterargp/parameter/paramdef
+  /funcprototype
+/funcsynopsis
+  /refsynopsisdiv
+
+  refsect1
+titleArguments/title
+
+variablelist
+  varlistentry
+   termparameterfd/parameter/term
+   listitem
+ parafd;/para
+   /listitem
+  /varlistentry
+  varlistentry
+   termparameterrequest/parameter/term
+   listitem
+ paraVIDIOC_DBG_G_CHIP_NAME/para
+   /listitem
+  /varlistentry
+  varlistentry
+   termparameterargp/parameter/term
+   listitem
+ para/para
+   /listitem
+  /varlistentry
+/variablelist
+  /refsect1
+
+  refsect1
+titleDescription/title
+
+note
+  titleExperimental/title
+
+  paraThis is an link
+linkend=experimentalexperimental/link interface and may change in
+the future./para
+/note
+
+paraFor driver debugging purposes this ioctl allows test
+applications to query the driver about the chips present on the TV
+card. Regular applications must not use it. When you found a chip
+specific bug, please contact the linux-media mailing list (v4l-ml;)
+so it can be fixed./para
+
+paraTo query the driver applications must initialize the
+structfieldmatch.type/structfield and
+structfieldmatch.addr/structfield or structfieldmatch.name/structfield
+fields of a v4l2-dbg-chip-name;
+and call 

[PATCH v2] drivers: staging: davinci_vpfe: use resource_size()

2013-03-18 Thread Silviu-Mihai Popescu
This uses the resource_size() function instead of explicit computation.

Signed-off-by: Silviu-Mihai Popescu silviupopescu1...@gmail.com
---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |2 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c|4 ++--
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index 9285353..05673ed 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -1859,5 +1859,5 @@ void vpfe_ipipe_cleanup(struct vpfe_ipipe_device *ipipe,
iounmap(ipipe-isp5_base_addr);
res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
if (res)
-   release_mem_region(res-start, res-end - res-start + 1);
+   release_mem_region(res-start, resource_size(res));
 }
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c 
b/drivers/staging/media/davinci_vpfe/dm365_isif.c
index ebeea72..c4a5660 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_isif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c
@@ -1953,7 +1953,7 @@ static void isif_remove(struct vpfe_isif_device *isif,
res = platform_get_resource(pdev, IORESOURCE_MEM, i);
if (res)
release_mem_region(res-start,
-  res-end - res-start + 1);
+  resource_size(res));
i++;
}
 }
@@ -2003,7 +2003,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct 
platform_device *pdev)
status = -ENOENT;
goto fail_nobase_res;
}
-   res_len = res-end - res-start + 1;
+   res_len = resource_size(res);
res = request_mem_region(res-start, res_len, res-name);
if (!res) {
status = -EBUSY;
diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c 
b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
index 9cb0262..126f84c 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
@@ -1995,5 +1995,5 @@ vpfe_resizer_cleanup(struct vpfe_resizer_device *vpfe_rsz,
res = platform_get_resource(pdev, IORESOURCE_MEM, 5);
if (res)
release_mem_region(res-start,
-   res-end - res-start + 1);
+   resource_size(res));
 }
-- 
1.7.9.5

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


Re: [PATCH] drivers: staging: davinci_vpfe: use resource_size()

2013-03-18 Thread Silviu Popescu
On Sun, Mar 17, 2013 at 3:38 PM, Prabhakar Lad
prabhakar.cse...@gmail.com wrote:
 Hi,

 Thanks for the patch!

 did you build test this patch ? the above header file(ioport.h) is not
 required in all the
 above files which you included.

 Cheers,
 --Prabhakar Lad

Hi,

It would seem I was a bit overzealous. Indeed, there was no need for
that extra include.
I've send a refreshed patch. Would you be so kind as to review it?

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


[PATCH 1/2] dvb-frontend: split set_delivery_system()

2013-03-18 Thread Mauro Carvalho Chehab
This function is complex, and has different workflows, one for
DVBv3 calls, and another one for DVBv5 calls. Break it into 3
functions, in order to make easier to understand what each
block does.

No functional changes so far. A few comments got improved.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-core/dvb_frontend.c | 292 +++---
 1 file changed, 164 insertions(+), 128 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index 6e50a75..bbc1965 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1509,132 +1509,12 @@ static bool is_dvbv3_delsys(u32 delsys)
return status;
 }
 
-static int set_delivery_system(struct dvb_frontend *fe, u32 desired_system)
+static int emulate_delivery_system(struct dvb_frontend *fe,
+  enum dvbv3_emulation_type type,
+  u32 delsys, u32 desired_system)
 {
-   int ncaps, i;
-   u32 delsys = SYS_UNDEFINED;
+   int i;
struct dtv_frontend_properties *c = fe-dtv_property_cache;
-   enum dvbv3_emulation_type type;
-
-   /*
-* It was reported that some old DVBv5 applications were
-* filling delivery_system with SYS_UNDEFINED. If this happens,
-* assume that the application wants to use the first supported
-* delivery system.
-*/
-   if (c-delivery_system == SYS_UNDEFINED)
-   c-delivery_system = fe-ops.delsys[0];
-
-   if (desired_system == SYS_UNDEFINED) {
-   /*
-* A DVBv3 call doesn't know what's the desired system.
-* Also, DVBv3 applications don't know that ops.info-type
-* could be changed, and they simply dies when it doesn't
-* match.
-* So, don't change the current delivery system, as it
-* may be trying to do the wrong thing, like setting an
-* ISDB-T frontend as DVB-T. Instead, find the closest
-* DVBv3 system that matches the delivery system.
-*/
-   if (is_dvbv3_delsys(c-delivery_system)) {
-   dev_dbg(fe-dvb-device,
-   %s: Using delivery system to %d\n,
-   __func__, c-delivery_system);
-   return 0;
-   }
-   type = dvbv3_type(c-delivery_system);
-   switch (type) {
-   case DVBV3_QPSK:
-   desired_system = SYS_DVBS;
-   break;
-   case DVBV3_QAM:
-   desired_system = SYS_DVBC_ANNEX_A;
-   break;
-   case DVBV3_ATSC:
-   desired_system = SYS_ATSC;
-   break;
-   case DVBV3_OFDM:
-   desired_system = SYS_DVBT;
-   break;
-   default:
-   dev_dbg(fe-dvb-device, %s: This frontend doesn't 
support DVBv3 calls\n,
-   __func__);
-   return -EINVAL;
-   }
-   /*
-* Get a delivery system that is compatible with DVBv3
-* NOTE: in order for this to work with softwares like Kaffeine 
that
-*  uses a DVBv5 call for DVB-S2 and a DVBv3 call to go 
back to
-*  DVB-S, drivers that support both should put the 
SYS_DVBS entry
-*  before the SYS_DVBS2, otherwise it won't switch back to 
DVB-S.
-*  The real fix is that userspace applications should not 
use DVBv3
-*  and not trust on calling FE_SET_FRONTEND to switch the 
delivery
-*  system.
-*/
-   ncaps = 0;
-   while (fe-ops.delsys[ncaps]  ncaps  MAX_DELSYS) {
-   if (fe-ops.delsys[ncaps] == desired_system) {
-   delsys = desired_system;
-   break;
-   }
-   ncaps++;
-   }
-   if (delsys == SYS_UNDEFINED) {
-   dev_dbg(fe-dvb-device, %s: Couldn't find a delivery 
system that matches %d\n,
-   __func__, desired_system);
-   }
-   } else {
-   /*
-* This is a DVBv5 call. So, it likely knows the supported
-* delivery systems.
-*/
-
-   /* Check if the desired delivery system is supported */
-   ncaps = 0;
-   while (fe-ops.delsys[ncaps]  ncaps  MAX_DELSYS) {
-   if (fe-ops.delsys[ncaps] == desired_system) {
-   c-delivery_system = desired_system;
- 

[PATCH 2/2] dvb_frontend: Simplify the emulation logic

2013-03-18 Thread Mauro Carvalho Chehab
The current logic was broken and too complex; while it works
fine for DVB-S2/DVB-S, it is broken for ISDB-T.

Make the logic simpler, fixes it for ISDB-T and make it clearer.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-core/dvb_frontend.c | 219 +-
 1 file changed, 109 insertions(+), 110 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index bbc1965..a7317ae 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1509,9 +1509,17 @@ static bool is_dvbv3_delsys(u32 delsys)
return status;
 }
 
-static int emulate_delivery_system(struct dvb_frontend *fe,
-  enum dvbv3_emulation_type type,
-  u32 delsys, u32 desired_system)
+/**
+ * emulate_delivery_system - emulate a DVBv5 delivery system with a DVBv3 type
+ * @fe:struct frontend;
+ * @desired_system:DVBv5 type that will be used for emulation
+ *
+ * Provides emulation for delivery systems that are compatible with the old
+ * DVBv3 call. Among its usages, it provices support for ISDB-T, and allows
+ * using a DVB-S2 only frontend just like it were a DVB-S, if the frontent
+ * parameters are compatible with DVB-S spec.
+ */
+static int emulate_delivery_system(struct dvb_frontend *fe, u32 delsys)
 {
int i;
struct dtv_frontend_properties *c = fe-dtv_property_cache;
@@ -1519,51 +1527,52 @@ static int emulate_delivery_system(struct dvb_frontend 
*fe,
c-delivery_system = delsys;
 
/*
-* The DVBv3 or DVBv5 call is requesting a different system. So,
-* emulation is needed.
-*
-* Emulate newer delivery systems like ISDBT, DVBT and DTMB
-* for older DVBv5 applications. The emulation will try to use
-* the auto mode for most things, and will assume that the desired
-* delivery system is the last one at the ops.delsys[] array
+* If the call is for ISDB-T, put it into full-seg, auto mode, TV
 */
-   dev_dbg(fe-dvb-device,
-   %s: Using delivery system %d emulated as if it were a %d\n,
-   __func__, delsys, desired_system);
+   if (c-delivery_system == SYS_ISDBT) {
+   dev_dbg(fe-dvb-device,
+   %s: Using defaults for SYS_ISDBT\n,
+   __func__);
 
-   /*
-* For now, handles ISDB-T calls. More code may be needed here for the
-* other emulated stuff
-*/
-   if (type == DVBV3_OFDM) {
-   if (c-delivery_system == SYS_ISDBT) {
-   dev_dbg(fe-dvb-device,
-   %s: Using defaults for SYS_ISDBT\n,
-   __func__);
-
-   if (!c-bandwidth_hz)
-   c-bandwidth_hz = 600;
-
-   c-isdbt_partial_reception = 0;
-   c-isdbt_sb_mode = 0;
-   c-isdbt_sb_subchannel = 0;
-   c-isdbt_sb_segment_idx = 0;
-   c-isdbt_sb_segment_count = 0;
-   c-isdbt_layer_enabled = 0;
-   for (i = 0; i  3; i++) {
-   c-layer[i].fec = FEC_AUTO;
-   c-layer[i].modulation = QAM_AUTO;
-   c-layer[i].interleaving = 0;
-   c-layer[i].segment_count = 0;
-   }
+   if (!c-bandwidth_hz)
+   c-bandwidth_hz = 600;
+
+   c-isdbt_partial_reception = 0;
+   c-isdbt_sb_mode = 0;
+   c-isdbt_sb_subchannel = 0;
+   c-isdbt_sb_segment_idx = 0;
+   c-isdbt_sb_segment_count = 0;
+   c-isdbt_layer_enabled = 7;
+   for (i = 0; i  3; i++) {
+   c-layer[i].fec = FEC_AUTO;
+   c-layer[i].modulation = QAM_AUTO;
+   c-layer[i].interleaving = 0;
+   c-layer[i].segment_count = 0;
}
}
dev_dbg(fe-dvb-device, %s: change delivery system on cache to %d\n,
-   __func__, c-delivery_system);
+   __func__, c-delivery_system);
 
return 0;
 }
 
+/**
+ * dvbv5_set_delivery_system - Sets the delivery system for a DVBv5 API call
+ * @fe:frontend struct
+ * @desired_system:delivery system requested by the user
+ *
+ * A DVBv5 call know what's the desired system it wants. So, set it.
+ *
+ * There are, however, a few known issues with early DVBv5 applications that
+ * are also handled by this logic:
+ *
+ * 1) Some early apps use SYS_UNDEFINED as the desired delivery system.
+ *This is an API violation, but, as we don't want to break userspace,
+ *convert it to 

cron job: media_tree daily build: WARNINGS

2013-03-18 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:   Mon Mar 18 19:00:23 CET 2013
git branch: test
git hash:   4d35435d3ffb853b491f5bb21a62529cd925d660
gcc version:i686-linux-gcc (GCC) 4.7.2
host hardware:  x86_64
host os:3.8.03-marune

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

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


[GIT PULL] IT913X

2013-03-18 Thread Antti Palosaari
That patch serie adds new silicon RF-tuner driver named IT913X and 
IT9135 support for existing AF9035/AF9033 drivers. IT913X driver is 
split out from the existing IT9135 driver.


IT913X serie is successor of AF903X serie. Difference is integrated 
RF-tuner. Also those two letters has changed from AF to IT as Afatech 
was bought by ITE Tech.


Logically there is three chips, as always in case of DTV USB device:
* USB-interface
* demodulator
* RF-tuner

These are sold as following chip names and integrated combinations:
* AF9032 = demodulator ?
* AF9033 = demodulator
* AF9035 = USB-interface + demodulator
* IT9133 = demodulator + RF-tuner
* IT9135 = USB-interface + demodulator + RF-tuner
* IT9137 = IT9135 + MPEG TS input for connecting extra IT9133


regards
Antti


The following changes since commit 4ca286610f664acf3153634f3930acd2de993a9f:

  [media] radio-rtrack2: fix mute bug (2013-03-05 15:20:07 -0300)

are available in the git repository at:

  git://linuxtv.org/anttip/media_tree.git it9135_tuner

for you to fetch changes up to 17f64e21efadad3da1744feec97a12d97df15765:

  MAINTAINERS: add drivers/media/tuners/it913x* (2013-03-10 03:58:13 +0200)


Antti Palosaari (41):
  ITE IT913X silicon tuner driver
  af9033: support for it913x tuners
  af9035: add support for 1st gen it9135
  af9035: add auto configuration heuristic for it9135
  af9035: fix af9033 demod sampling frequency
  af9015: reject device TerraTec Cinergy T Stick Dual RC (rev. 2)
  af9035: [0ccd:0099] TerraTec Cinergy T Stick Dual RC (rev. 2)
  af9035: constify clock tables
  af9035: USB1.1 support (== PID filters)
  af9035: merge af9035 and it9135 eeprom read routines
  af9035: basic support for IT9135 v2 chips
  af9033: IT9135 v2 supported related changes
  af9035: IT9135 dual tuner related changes
  it913x: merge it913x_fe_start() to it913x_init_tuner()
  it913x: merge it913x_fe_suspend() to it913x_fe_sleep()
  it913x: rename functions and variables
  it913x: tuner power up routines
  it913x: get rid of it913x config struct
  it913x: remove unused variables
  it913x: include tuner IDs from af9033.h
  it913x: use dev_foo() logging
  af9033: add IT9135 demod reg init tables
  it913x: remove demod init reg tables
  af9035: select firmware loader according to firmware
  af9035: use already detected eeprom base addr
  af9035: set demod TS mode config in read_config()
  af9035: enable remote controller for IT9135 too
  af9035: change dual mode boolean to bit field
  af9033: add IT9135 tuner config 38 init table
  af9033: add IT9135 tuner config 51 init table
  af9033: add IT9135 tuner config 52 init table
  af9033: add IT9135 tuner config 60 init table
  af9033: add IT9135 tuner config 61 init table
  af9033: add IT9135 tuner config 62 init table
  it913x: remove unused af9033 demod tuner config inits
  af9033: move code from it913x to af9033
  af9033: sleep on attach()
  af9033: implement i/o optimized reg table writer
  af9035: check I/O errors on IR polling
  af9035: style changes for remote controller polling
  MAINTAINERS: add drivers/media/tuners/it913x*

 MAINTAINERS   |   10 +
 drivers/media/dvb-frontends/af9033.c  |  138 ++---
 drivers/media/dvb-frontends/af9033.h  |   15 ++
 drivers/media/dvb-frontends/af9033_priv.h | 1506 
+-

 drivers/media/tuners/Kconfig  |7 +
 drivers/media/tuners/Makefile |1 +
 drivers/media/tuners/it913x.c |  447 


 drivers/media/tuners/it913x.h |   45 
 drivers/media/tuners/it913x_priv.h|   78 +++
 drivers/media/usb/dvb-usb-v2/Kconfig  |1 +
 drivers/media/usb/dvb-usb-v2/af9015.c |   40 +++-
 drivers/media/usb/dvb-usb-v2/af9035.c |  545 
-

 drivers/media/usb/dvb-usb-v2/af9035.h |   47 +++--
 13 files changed, 2654 insertions(+), 226 deletions(-)
 create mode 100644 drivers/media/tuners/it913x.c
 create mode 100644 drivers/media/tuners/it913x.h
 create mode 100644 drivers/media/tuners/it913x_priv.h

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


[PATCH] [media] Add a V4L2 OF parser

2013-03-18 Thread Sylwester Nawrocki
From: Guennadi Liakhovetski g.liakhovet...@gmx.de

Add a V4L2 OF parser, implementing bindings documented in
Documentation/devicetree/bindings/media/video-interfaces.txt.

Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
[s.nawro...@samsung.com: various corrections and improvements
since the initial version]
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com

---
Geunnadi,

I have made couple further changes to this parsing library, mostly
addressing your review comments. Hopefully it looks better now.

It would be good to get more reviews and opinions of other media
sub-maintainers. Any Acked/Tested-by are also of course most
welcome.

I have a feeling this is about ready for upstream ;-) We have
used it in couple subsystems already and the overall design
looks good and seems to be proving itself in practice.

Thanks,
Sylwester

The last version of the bindings documentation patch can be found
at: https://patchwork.kernel.org/patch/2074951

Changes since v7 include mostly corrections of issues pointed
out by Guennadi, and few others:

 - v4l2_of_parse_parallel_bus() and v4l2_of_parse_csi_bus() are
   made static and are not exported anymore;
 - swapped order of parsing the serial and parallel bus properties
   in v4l2_of_parse_endpoint() function; the rationale is that
   MIPI CSI-2 has less properties and an overall number of searches
   of non-existent properties is less this way;
 - v4l2_mbus_mipi_csi2, v4l2_mbus_parallel structs renamed to
   v4l2_of_bus_mipi_csi2, v4l2_of_bus_parallel respectively;
 - added kernel-doc for the above two data structures;
 - the flags field split into to fields - separate fields for the
   parallel and serial bus, V4L2_MBUS_* bit flags are defined
   separately for MIPI CSI-2 and parallel busses so they were
   clashing when used together in single data structure member!;
 - the head member of struct v4l2_endpoint made last member of
   this data structure, it is now not cleared with memset() at the
   beginning of v4l2_of_parse_endpoint() function; I believe
   clearing list head in this function is not expected;
 - fixed bug in v4l2_of_get_remote_port_parent() function;
 - reworked first port node searching in v4l2_of_get_next_endpoint();
 - moved code setting V4L2_MBUS_MASTER and V4L2_MBUS_CSI2_CONTINUOUS_CLOCK
   out from v4l2_of_parse_endpoint() to v4l2_of_parse_mipi_csi2/
   parallel_bus() functions;
 - ensured we recognize presence of the clock-lanes property regardless
   of the clock lane index being 0;
 - added v4l2_of_get_remote_port() function.

Changes since v6:
 - minor v4l2_of_get_remote_port_parent() function cleanup.

Changes since v5:
 - renamed v4l2_of_parse_mipi_csi2 - v4l2_of_parse_csi_bus;
 - corrected v4l2_of_get_remote_port_parent() function declaration
   for !CONFIG_OF;
 - reworked v4l2_of_get_next_endpoint() function to consider the
   'port' nodes can be grouped under optional 'ports' node;
 - added kerneldoc description for v4l2_of_get_next_endpoint()
   function.

Changes since v4:
 - reworked v4l2_of_get_remote_port() function to consider cases
   where 'port' nodes are grouped in a parent 'ports' node;
 - rearranged struct v4l2_of_endpoint and related changes added
   in the parser code;
 - added kerneldoc description for struct v4l2_of_endpoint;
 - s/link/endpoint in the comments.
---
 drivers/media/v4l2-core/Makefile  |3 +
 drivers/media/v4l2-core/v4l2-of.c |  267 +
 include/media/v4l2-of.h   |  111 +++
 3 files changed, 381 insertions(+)
 create mode 100644 drivers/media/v4l2-core/v4l2-of.c
 create mode 100644 include/media/v4l2-of.h

diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index c2d61d4..00f64d6 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -9,6 +9,9 @@ videodev-objs   :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o 
v4l2-fh.o \
 ifeq ($(CONFIG_COMPAT),y)
   videodev-objs += v4l2-compat-ioctl32.o
 endif
+ifeq ($(CONFIG_OF),y)
+  videodev-objs += v4l2-of.o
+endif

 obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-int-device.o
 obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o
diff --git a/drivers/media/v4l2-core/v4l2-of.c 
b/drivers/media/v4l2-core/v4l2-of.c
new file mode 100644
index 000..e38e210
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -0,0 +1,267 @@
+/*
+ * V4L2 OF binding parsing library
+ *
+ * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
+ * Sylwester Nawrocki s.nawro...@samsung.com
+ *
+ * Copyright (C) 2012 Renesas Electronics Corp.
+ * Author: Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ */
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of.h
+#include linux/string.h
+#include 

Re: [PATCH 2/2] dvb_frontend: Simplify the emulation logic

2013-03-18 Thread Fabio Estevam
Hi Mauro,

On Mon, Mar 18, 2013 at 4:25 PM, Mauro Carvalho Chehab
mche...@redhat.com wrote:

 -static int emulate_delivery_system(struct dvb_frontend *fe,
 -  enum dvbv3_emulation_type type,
 -  u32 delsys, u32 desired_system)
 +/**
 + * emulate_delivery_system - emulate a DVBv5 delivery system with a DVBv3 
 type
 + * @fe:struct frontend;
 + * @desired_system:DVBv5 type that will be used for emulation

'desired_system' parameter has been removed in this patch. 'delsys'
should be put in the description instead.

 + * Provides emulation for delivery systems that are compatible with the old
 + * DVBv3 call. Among its usages, it provices support for ISDB-T, and allows
 + * using a DVB-S2 only frontend just like it were a DVB-S, if the frontent
 + * parameters are compatible with DVB-S spec.
 + */
 +static int emulate_delivery_system(struct dvb_frontend *fe, u32 delsys)

Regards,

Fabio Estevam
--
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 v7 1/9] mfd: Add commands abstraction layer for SI476X MFD

2013-03-18 Thread Mauro Carvalho Chehab
Em Tue, 26 Feb 2013 22:06:45 -0800
Andrey Smirnov andrew.smir...@gmail.com escreveu:

 This patch adds all the functions used for exchanging commands with
 the chip.

Please run checkpatch.pl over those patches. There are a number of compliants
on those patches:

WARNING: externs should be avoided in .c files
#210: FILE: drivers/mfd/si476x-cmd.c:180:
+int si476x_core_i2c_xfer(struct si476x_core *,

WARNING: line over 80 characters
#328: FILE: drivers/mfd/si476x-cmd.c:298:
+   err = si476x_core_i2c_xfer(core, SI476X_I2C_SEND, (char *) data, argn + 
1);

WARNING: line over 80 characters
#378: FILE: drivers/mfd/si476x-cmd.c:348:
+   dev_err(core-client-dev, [CMD 0x%02x] Chip set error 
flag\n, command);

ERROR: space required before the open parenthesis '('
#400: FILE: drivers/mfd/si476x-cmd.c:370:
+   switch(core-power_up_parameters.func) {

...


 
 Acked-by: Hans Verkuil hans.verk...@cisco.com
 Signed-off-by: Andrey Smirnov andrew.smir...@gmail.com
 ---
  drivers/mfd/si476x-cmd.c | 1553 
 ++
  1 file changed, 1553 insertions(+)
  create mode 100644 drivers/mfd/si476x-cmd.c
 
 diff --git a/drivers/mfd/si476x-cmd.c b/drivers/mfd/si476x-cmd.c
 new file mode 100644
 index 000..0ae1b63
 --- /dev/null
 +++ b/drivers/mfd/si476x-cmd.c
 @@ -0,0 +1,1553 @@
 +/*
 + * drivers/mfd/si476x-cmd.c -- Subroutines implementing command
 + * protocol of si476x series of chips
 + *
 + * Copyright (C) 2012 Innovative Converged Devices(ICD)
 + * Copyright (C) 2013 Andrey Smirnov
 + *
 + * Author: Andrey Smirnov andrew.smir...@gmail.com
 + *
 + * 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
 +
 +#define CMD_AGC_STATUS   0x17
 +#define CMD_AGC_STATUS_NRESP_A10 2
 +#define CMD_AGC_STATUS_NRESP_A206
 +
 +#define PIN_CFG_BYTE(x) (0x7F  (x))
 +#define CMD_DIG_AUDIO_PIN_CFG0x18
 +#define CMD_DIG_AUDIO_PIN_CFG_NARGS  4
 +#define CMD_DIG_AUDIO_PIN_CFG_NRESP  5
 +
 +#define CMD_ZIF_PIN_CFG  0x19
 +#define CMD_ZIF_PIN_CFG_NARGS4
 +#define CMD_ZIF_PIN_CFG_NRESP5
 +
 +#define CMD_IC_LINK_GPO_CTL_PIN_CFG  0x1A
 +#define CMD_IC_LINK_GPO_CTL_PIN_CFG_NARGS4
 +#define CMD_IC_LINK_GPO_CTL_PIN_CFG_NRESP5
 +
 +#define CMD_ANA_AUDIO_PIN_CFG0x1B
 +#define CMD_ANA_AUDIO_PIN_CFG_NARGS  1
 +#define CMD_ANA_AUDIO_PIN_CFG_NRESP  2
 +
 +#define CMD_INTB_PIN_CFG 0x1C
 +#define CMD_INTB_PIN_CFG_NARGS   2
 +#define CMD_INTB_PIN_CFG_A10_NRESP   6
 +#define CMD_INTB_PIN_CFG_A20_NRESP   3
 +
 +#define CMD_FM_TUNE_FREQ 0x30
 +#define CMD_FM_TUNE_FREQ_A10_NARGS   5
 +#define CMD_FM_TUNE_FREQ_A20_NARGS   3
 +#define CMD_FM_TUNE_FREQ_NRESP   1
 +
 +#define CMD_FM_RSQ_STATUS0x32
 +
 +#define CMD_FM_RSQ_STATUS_A10_NARGS  1
 +#define CMD_FM_RSQ_STATUS_A10_NRESP  17
 +#define CMD_FM_RSQ_STATUS_A30_NARGS  1
 +#define 

[GIT PULL] dvb_usb_v2: PID filter and streaming ctrl related changes

2013-03-18 Thread Antti Palosaari
This fix one bug where sync lock is hold over the userspace. Also it 
changes dvb_usb_v2 PID filter logic a little bit.


regards
Antti


The following changes since commit 4ca286610f664acf3153634f3930acd2de993a9f:

  [media] radio-rtrack2: fix mute bug (2013-03-05 15:20:07 -0300)

are available in the git repository at:

  git://linuxtv.org/anttip/media_tree.git dvb_usb_v2_pid_filter

for you to fetch changes up to 0d3f7b6d19f230fd73ceefbe370844c7e0b67357:

  it913x: fix pid filter (2013-03-18 22:21:31 +0200)


Antti Palosaari (5):
  dvb_usb_v2: replace Kernel userspace lock with wait queue
  dvb_usb_v2: make checkpatch.pl happy
  cypress_firmware: make checkpatch.pl happy
  dvb_usb_v2: rework USB streaming logic
  it913x: fix pid filter

 drivers/media/usb/dvb-usb-v2/cypress_firmware.c |   5 +--
 drivers/media/usb/dvb-usb-v2/dvb_usb.h  |   5 ++-
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 311 
+

 drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c  |   5 ++-
 drivers/media/usb/dvb-usb-v2/it913x.c   |   1 +
 drivers/media/usb/dvb-usb-v2/usb_urb.c  |  36 ---
 6 files changed, 206 insertions(+), 157 deletions(-)

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


Re: [GIT PULL] IT913X

2013-03-18 Thread Antti Palosaari

I rebased it as Mauro just committed some stuff that causes merge conflict!

Antti

On 03/18/2013 09:50 PM, Antti Palosaari wrote:

That patch serie adds new silicon RF-tuner driver named IT913X and
IT9135 support for existing AF9035/AF9033 drivers. IT913X driver is
split out from the existing IT9135 driver.

IT913X serie is successor of AF903X serie. Difference is integrated
RF-tuner. Also those two letters has changed from AF to IT as Afatech
was bought by ITE Tech.

Logically there is three chips, as always in case of DTV USB device:
* USB-interface
* demodulator
* RF-tuner

These are sold as following chip names and integrated combinations:
* AF9032 = demodulator ?
* AF9033 = demodulator
* AF9035 = USB-interface + demodulator
* IT9133 = demodulator + RF-tuner
* IT9135 = USB-interface + demodulator + RF-tuner
* IT9137 = IT9135 + MPEG TS input for connecting extra IT9133


regards
Antti


The following changes since commit
4ca286610f664acf3153634f3930acd2de993a9f:

   [media] radio-rtrack2: fix mute bug (2013-03-05 15:20:07 -0300)

are available in the git repository at:

   git://linuxtv.org/anttip/media_tree.git it9135_tuner

for you to fetch changes up to 17f64e21efadad3da1744feec97a12d97df15765:

   MAINTAINERS: add drivers/media/tuners/it913x* (2013-03-10 03:58:13
+0200)


Antti Palosaari (41):
   ITE IT913X silicon tuner driver
   af9033: support for it913x tuners
   af9035: add support for 1st gen it9135
   af9035: add auto configuration heuristic for it9135
   af9035: fix af9033 demod sampling frequency
   af9015: reject device TerraTec Cinergy T Stick Dual RC (rev. 2)
   af9035: [0ccd:0099] TerraTec Cinergy T Stick Dual RC (rev. 2)
   af9035: constify clock tables
   af9035: USB1.1 support (== PID filters)
   af9035: merge af9035 and it9135 eeprom read routines
   af9035: basic support for IT9135 v2 chips
   af9033: IT9135 v2 supported related changes
   af9035: IT9135 dual tuner related changes
   it913x: merge it913x_fe_start() to it913x_init_tuner()
   it913x: merge it913x_fe_suspend() to it913x_fe_sleep()
   it913x: rename functions and variables
   it913x: tuner power up routines
   it913x: get rid of it913x config struct
   it913x: remove unused variables
   it913x: include tuner IDs from af9033.h
   it913x: use dev_foo() logging
   af9033: add IT9135 demod reg init tables
   it913x: remove demod init reg tables
   af9035: select firmware loader according to firmware
   af9035: use already detected eeprom base addr
   af9035: set demod TS mode config in read_config()
   af9035: enable remote controller for IT9135 too
   af9035: change dual mode boolean to bit field
   af9033: add IT9135 tuner config 38 init table
   af9033: add IT9135 tuner config 51 init table
   af9033: add IT9135 tuner config 52 init table
   af9033: add IT9135 tuner config 60 init table
   af9033: add IT9135 tuner config 61 init table
   af9033: add IT9135 tuner config 62 init table
   it913x: remove unused af9033 demod tuner config inits
   af9033: move code from it913x to af9033
   af9033: sleep on attach()
   af9033: implement i/o optimized reg table writer
   af9035: check I/O errors on IR polling
   af9035: style changes for remote controller polling
   MAINTAINERS: add drivers/media/tuners/it913x*

  MAINTAINERS   |   10 +
  drivers/media/dvb-frontends/af9033.c  |  138 ++---
  drivers/media/dvb-frontends/af9033.h  |   15 ++
  drivers/media/dvb-frontends/af9033_priv.h | 1506
+-

  drivers/media/tuners/Kconfig  |7 +
  drivers/media/tuners/Makefile |1 +
  drivers/media/tuners/it913x.c |  447

  drivers/media/tuners/it913x.h |   45 
  drivers/media/tuners/it913x_priv.h|   78 +++
  drivers/media/usb/dvb-usb-v2/Kconfig  |1 +
  drivers/media/usb/dvb-usb-v2/af9015.c |   40 +++-
  drivers/media/usb/dvb-usb-v2/af9035.c |  545
-
  drivers/media/usb/dvb-usb-v2/af9035.h |   47 +++--
  13 files changed, 2654 insertions(+), 226 deletions(-)
  create mode 100644 drivers/media/tuners/it913x.c
  create mode 100644 drivers/media/tuners/it913x.h
  create mode 100644 drivers/media/tuners/it913x_priv.h




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


Re: [PATCH 0/3] em28xx: add support for two buses on em2874 and upper

2013-03-18 Thread Mauro Carvalho Chehab
Em Tue, 5 Mar 2013 10:43:10 -0500
Devin Heitmueller dheitmuel...@kernellabs.com escreveu:

 2013/3/5 Mauro Carvalho Chehab mche...@redhat.com:
  The em2874 chips and upper have 2 buses. On all known devices, bus 0 is
  currently used only by eeprom, and bus 1 for the rest. Add support to
  register both buses.
 
 Did you add a mutex to ensure that both buses cannot be used at the
 same time?  Because using the bus requires you to toggle a register
 (thus you cannot be using both busses at the same time), you cannot
 rely on the existing i2c adapter lock anymore.
 
 You don't want a situation where something is actively talking on bus
 0, and then something else tries to talk on bus 1, flips the register
 bit and then the thread talking on bus 0 starts failing.

Good point. The I2C mutex won't solve for this case. I'll add a mutex
there at the xfer function on a separate patch.

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


Re: [PATCH 0/3] em28xx: add support for two buses on em2874 and upper

2013-03-18 Thread Mauro Carvalho Chehab
Em Wed, 06 Mar 2013 18:44:07 +0100
Frank Schäfer fschaefer@googlemail.com escreveu:

 Am 05.03.2013 16:43, schrieb Devin Heitmueller:
  2013/3/5 Mauro Carvalho Chehab mche...@redhat.com:
  The em2874 chips and upper have 2 buses. On all known devices, bus 0 is
  currently used only by eeprom, and bus 1 for the rest. Add support to
  register both buses.
  Did you add a mutex to ensure that both buses cannot be used at the
  same time?  Because using the bus requires you to toggle a register
  (thus you cannot be using both busses at the same time), you cannot
  rely on the existing i2c adapter lock anymore.
 
  You don't want a situation where something is actively talking on bus
  0, and then something else tries to talk on bus 1, flips the register
  bit and then the thread talking on bus 0 starts failing.
 
  Devin
 
 Hmm... there are several writes to EM28XX_R06_I2C_CLK in em28xx-dvb...
 See hauppauge_hvr930c_init(), terratec_h5_init() and
 terratec_htc_stick_init().
 These functions are called from em28xx_dvb_init() at module init.
 Module init is async, so yes, this is (or could at least become) a
 problem...
 
 I wonder if we can't simply remove all those writes to
 EM28XX_R06_I2C_CLK from em28xx-dvb.
 This is what the functions are doing:
 
 hauppauge_hvr930c_init()
 ...
 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
 msleep(10);
 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44);
 msleep(10);
 ... [init sequence for slave at address 0x82]
 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44);
 msleep(30);
 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x45);
 msleep(10);
 
 terratec_h5_init():
 ...
 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
 msleep(10);
 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x45);
 msleep(10);
 ...
 
 terratec_htc_stick_init()
 ...
 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
 msleep(10);
 em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44);
 msleep(10);
 ...
 
 All three boards are using the following settings:
 .i2c_speed= EM2874_I2C_SECONDARY_BUS_SELECT |
 EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_400_KHZ = 0x45
 
 So what these functions are doing is
 - switch to bus A and do nothing fo 10ms
 - overwrite board settings for reg 0x06 with a local value (clears
 EM28XX_I2C_FREQ_400_KHZ permanently for the HTC-Stick !).
 
 I can test the HVR-930C next week.

There are some things there on the init sequence that can be
cleaned/removed. Those sequences generally comes from observing
what the original driver does. While it produces a working driver,
in general, it is not optimized and part of the init sequence can
be removed.

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


Re: [PATCH 2/3] em28xx: Add a separate config dir for secondary bus

2013-03-18 Thread Mauro Carvalho Chehab
Em Wed, 06 Mar 2013 17:40:44 +0100
Frank Schäfer fschaefer@googlemail.com escreveu:

 Am 05.03.2013 11:55, schrieb Mauro Carvalho Chehab:
  Prepare to register a separate bus for the second bus.
 
  For now, just add a new field. A latter patch will add the
  bits to make it work.
 
  This patch was generated by this script:
 
  perl -e 'while () { if (s/EM2874_I2C_SECONDARY_BUS_SELECT.*\n//) {
  printf \t\t.def_i2c_bus  = 1,\n; $found = 1; print $_ } else { if 
  ($found) { s/^\s+// }; $found = 0; print $_; } }' \
  drivers/media/usb/em28xx/em28xx-cards.c a  mv a 
  drivers/media/usb/em28xx/em28xx-cards.c
 
  Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
  ---
   drivers/media/usb/em28xx/em28xx-cards.c | 43 
  ++---
   drivers/media/usb/em28xx/em28xx.h   |  1 +
   2 files changed, 24 insertions(+), 20 deletions(-)
 
  diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
  b/drivers/media/usb/em28xx/em28xx-cards.c
  index d81f7ee..16ab4d7 100644
  --- a/drivers/media/usb/em28xx/em28xx-cards.c
  +++ b/drivers/media/usb/em28xx/em28xx-cards.c
  @@ -958,8 +958,8 @@ struct em28xx_board em28xx_boards[] = {
   #else
  .tuner_type   = TUNER_ABSENT,
   #endif
  -   .i2c_speed= EM2874_I2C_SECONDARY_BUS_SELECT |
  -   EM28XX_I2C_CLK_WAIT_ENABLE |
  +   .def_i2c_bus  = 1,
  +   .i2c_speed= EM28XX_I2C_CLK_WAIT_ENABLE |
  EM28XX_I2C_FREQ_400_KHZ,
 ...
 
 Looks good, we need a separate field like this for em2765 and Co., too
 (which don't use reg 0x06 for bus switching).

Feel free to add it when sending the patches for em2765.

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


Re: [PATCH v6 1/7] media: V4L2: add temporary clock helpers

2013-03-18 Thread Sylwester Nawrocki

Hi Guennadi,

On 03/15/2013 10:27 PM, Guennadi Liakhovetski wrote:

Typical video devices like camera sensors require an external clock source.
Many such devices cannot even access their hardware registers without a
running clock. These clock sources should be controlled by their consumers.
This should be performed, using the generic clock framework. Unfortunately
so far only very few systems have been ported to that framework. This patch


It seems there is much more significant progress in adding CCF support to
various platforms than with our temporary clocks API ;)

$ git show linux-next/master:drivers/clk/Makefile
...
# SoCs specific
obj-$(CONFIG_ARCH_BCM2835)  += clk-bcm2835.o
obj-$(CONFIG_ARCH_NOMADIK)  += clk-nomadik.o
obj-$(CONFIG_ARCH_HIGHBANK) += clk-highbank.o
obj-$(CONFIG_ARCH_MXS)  += mxs/
obj-$(CONFIG_ARCH_SOCFPGA)  += socfpga/
obj-$(CONFIG_PLAT_SPEAR)+= spear/
obj-$(CONFIG_ARCH_U300) += clk-u300.o
obj-$(CONFIG_COMMON_CLK_VERSATILE) += versatile/
obj-$(CONFIG_ARCH_PRIMA2)   += clk-prima2.o
obj-$(CONFIG_PLAT_ORION)+= mvebu/
ifeq ($(CONFIG_COMMON_CLK), y)
obj-$(CONFIG_ARCH_MMP)  += mmp/
endif
obj-$(CONFIG_MACH_LOONGSON1)+= clk-ls1x.o
obj-$(CONFIG_ARCH_U8500)+= ux500/
obj-$(CONFIG_ARCH_VT8500)   += clk-vt8500.o
obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
obj-$(CONFIG_ARCH_TEGRA)+= tegra/
obj-$(CONFIG_PLAT_SAMSUNG)  += samsung/

obj-$(CONFIG_X86)   += x86/

# Chip specific
obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
obj-$(CONFIG_CLK_TWL6040)   += clk-twl6040.o



adds a set of temporary helpers, mimicking the generic clock API, to V4L2.
Platforms, adopting the clock API, should switch to using it. Eventually
this temporary API should be removed.

Signed-off-by: Guennadi Liakhovetskig.liakhovet...@gmx.de
---

v6: changed clock name to justI2C adapter ID-I2C address  to avoid
having to wait for an I2C subdevice driver to probe. Added a subdevice
pointer to struct v4l2_clk for subdevice and bridge binding.

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

diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index a9d3552..aea7aea 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -5,7 +5,7 @@
  tuner-objs:=  tuner-core.o

  videodev-objs :=  v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
-   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o
+   v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o
  ifeq ($(CONFIG_COMPAT),y)
videodev-objs += v4l2-compat-ioctl32.o
  endif
diff --git a/drivers/media/v4l2-core/v4l2-clk.c 
b/drivers/media/v4l2-core/v4l2-clk.c
new file mode 100644
index 000..3505972
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-clk.c
@@ -0,0 +1,184 @@
+/*
+ * V4L2 clock service
+ *
+ * Copyright (C) 2012, Guennadi Liakhovetskig.liakhovet...@gmx.de


2013 ?


+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#includelinux/atomic.h
+#includelinux/errno.h
+#includelinux/list.h
+#includelinux/module.h
+#includelinux/mutex.h
+#includelinux/string.h
+
+#includemedia/v4l2-clk.h
+#includemedia/v4l2-subdev.h
+
+static DEFINE_MUTEX(clk_lock);
+static LIST_HEAD(clk_list);
+
+static struct v4l2_clk *v4l2_clk_find(const struct v4l2_subdev *sd,
+ const char *dev_id, const char *id)
+{
+   struct v4l2_clk *clk;
+
+   list_for_each_entry(clk,clk_list, list) {
+   if (!sd || !(sd-flags  V4L2_SUBDEV_FL_IS_I2C)) {
+   if (strcmp(dev_id, clk-dev_id))
+   continue;
+   } else {
+   char *i2c = strstr(dev_id, clk-dev_id);
+   if (!i2c || i2c == dev_id || *(i2c - 1) != ' ')
+   continue;
+   }
+
+   if (!id || !clk-id || !strcmp(clk-id, id))
+   return clk;
+   }
+
+   return ERR_PTR(-ENODEV);
+}
+
+struct v4l2_clk *v4l2_clk_get(struct v4l2_subdev *sd, const char *id)
+{
+   struct v4l2_clk *clk;
+
+   mutex_lock(clk_lock);
+   clk = v4l2_clk_find(sd, sd-name, id);


Couldn't we just pass the I2C client's struct device name to this function ?
And if the host driver that registers a clock for its sub-device knows 
the type
of device (I2C, SPI client, etc.) why we need to even bother with 
checking the
subdev/bus type in v4l2_clk_find() function above, when the 

Re: [PATCH 3/3] em28xx: add support for registering multiple i2c buses

2013-03-18 Thread Mauro Carvalho Chehab
Em Wed, 06 Mar 2013 17:53:19 +0100
Frank Schäfer fschaefer@googlemail.com escreveu:

 Hi Mauro,
 
 I'm basically fine this patch, just a few comments/thoughts:
 
 Am 05.03.2013 11:55, schrieb Mauro Carvalho Chehab:
  Register both buses 0 and 1 via I2C API. For now, bus 0 is used
  only by eeprom on all known devices. Later patches will be needed
  if this changes in the future.
 
  Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
  ---
   drivers/media/usb/em28xx/em28xx-cards.c | 29 +++---
   drivers/media/usb/em28xx/em28xx-i2c.c   | 93 
  ++---
   drivers/media/usb/em28xx/em28xx.h   | 19 +--
   3 files changed, 97 insertions(+), 44 deletions(-)
 
  diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
  b/drivers/media/usb/em28xx/em28xx-cards.c
  index 16ab4d7..496b938 100644
  --- a/drivers/media/usb/em28xx/em28xx-cards.c
  +++ b/drivers/media/usb/em28xx/em28xx-cards.c
  @@ -2235,8 +2235,8 @@ static inline void em28xx_set_model(struct em28xx 
  *dev)
  dev-board.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
 EM28XX_I2C_FREQ_100_KHZ;
   
  -   if (dev-board.def_i2c_bus == 1)
  -   dev-board.i2c_speed |= EM2874_I2C_SECONDARY_BUS_SELECT;
  +   /* Should be initialized early, for I2C to work */
  +   dev-def_i2c_bus = dev-board.def_i2c_bus;
   }
   
   
  @@ -2642,7 +2642,7 @@ static int em28xx_hint_board(struct em28xx *dev)
   
  /* user did not request i2c scanning = do it now */
  if (!dev-i2c_hash)
  -   em28xx_do_i2c_scan(dev);
  +   em28xx_do_i2c_scan(dev, dev-def_i2c_bus);
   
  for (i = 0; i  ARRAY_SIZE(em28xx_i2c_hash); i++) {
  if (dev-i2c_hash == em28xx_i2c_hash[i].hash) {
  @@ -2953,7 +2953,9 @@ void em28xx_release_resources(struct em28xx *dev)
   
  em28xx_release_analog_resources(dev);
   
  -   em28xx_i2c_unregister(dev);
  +   if (dev-def_i2c_bus)
  +   em28xx_i2c_unregister(dev, 1);
  +   em28xx_i2c_unregister(dev, 0);
   
  v4l2_ctrl_handler_free(dev-ctrl_handler);
   
  @@ -3109,14 +3111,23 @@ static int em28xx_init_dev(struct em28xx *dev, 
  struct usb_device *udev,
  v4l2_ctrl_handler_init(hdl, 8);
  dev-v4l2_dev.ctrl_handler = hdl;
   
  -   /* register i2c bus */
  -   retval = em28xx_i2c_register(dev);
  +   /* register i2c bus 0 */
  +   retval = em28xx_i2c_register(dev, 0);
  if (retval  0) {
  -   em28xx_errdev(%s: em28xx_i2c_register - error [%d]!\n,
  +   em28xx_errdev(%s: em28xx_i2c_register bus 0 - error [%d]!\n,
  __func__, retval);
  goto unregister_dev;
  }
   
  +   if (dev-def_i2c_bus) {
  +   retval = em28xx_i2c_register(dev, 1);
 
 Hmm, ok, so you don't want to register unused busses ?

No, the reason here is to just not register it if the device has just
one bus. Ok, the driver could simply check for the em28xx chipset type,
but it sounded easier and cleaner to just check for this field.

 What about bus A when all subdevices are on bus B ?

Currently, there's no such case. If we ever find a device like that, then
we can change the logic. Doing it in advance sounds an overkill to me.

 You don't have to register the adapter for eeprom reading, the i2c
 transfer functions work with unregistered i2c_adapters, too.

Yes, I know it is possible to hack it. However, that makes the code
more complex to read and understand, as, on other drivers, each different
I2C bus is mapped as a different I2C adapter.

 
  +   if (retval  0) {
  +   em28xx_errdev(%s: em28xx_i2c_register bus 1 - error 
  [%d]!\n,
  +   __func__, retval);
  +   goto unregister_dev;
  +   }
  +   }
  +
  /*
   * Default format, used for tvp5150 or saa711x output formats
   */
  @@ -3186,7 +3197,9 @@ static int em28xx_init_dev(struct em28xx *dev, struct 
  usb_device *udev,
  return 0;
   
   fail:
  -   em28xx_i2c_unregister(dev);
  +   if (dev-def_i2c_bus)
  +   em28xx_i2c_unregister(dev, 1);
  +   em28xx_i2c_unregister(dev, 0);
  v4l2_ctrl_handler_free(dev-ctrl_handler);
   
   unregister_dev:
  diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c 
  b/drivers/media/usb/em28xx/em28xx-i2c.c
  index 9086e57..ea63ac4 100644
  --- a/drivers/media/usb/em28xx/em28xx-i2c.c
  +++ b/drivers/media/usb/em28xx/em28xx-i2c.c
  @@ -280,9 +280,22 @@ static int em28xx_i2c_check_for_device(struct em28xx 
  *dev, u16 addr)
   static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
 struct i2c_msg msgs[], int num)
   {
  -   struct em28xx *dev = i2c_adap-algo_data;
  +   struct em28xx_i2c_bus *i2c_bus = i2c_adap-algo_data;
  +   struct em28xx *dev = i2c_bus-dev;
  +   unsigned bus = i2c_bus-bus, last_bus;
  int addr, rc, i, byte;
   
  +   /* Switch I2C bus if needed */
  +   last_bus = (dev-board.i2c_speed  EM2874_I2C_SECONDARY_BUS_SELECT) ?
  +  1 : 0;
  +   if 

Re: [GIT PULL] IT913X

2013-03-18 Thread Mauro Carvalho Chehab
Em Mon, 18 Mar 2013 23:04:17 +0200
Antti Palosaari cr...@iki.fi escreveu:

 I rebased it as Mauro just committed some stuff that causes merge conflict!

Well, if the conflicts are trivial, there's no need to rebase. There are
several patches that I use rebase when merging. Of course, rebasing it
saves me some time ;)

Regards,
Mauro
 
 Antti
 
 On 03/18/2013 09:50 PM, Antti Palosaari wrote:
  That patch serie adds new silicon RF-tuner driver named IT913X and
  IT9135 support for existing AF9035/AF9033 drivers. IT913X driver is
  split out from the existing IT9135 driver.
 
  IT913X serie is successor of AF903X serie. Difference is integrated
  RF-tuner. Also those two letters has changed from AF to IT as Afatech
  was bought by ITE Tech.
 
  Logically there is three chips, as always in case of DTV USB device:
  * USB-interface
  * demodulator
  * RF-tuner
 
  These are sold as following chip names and integrated combinations:
  * AF9032 = demodulator ?
  * AF9033 = demodulator
  * AF9035 = USB-interface + demodulator
  * IT9133 = demodulator + RF-tuner
  * IT9135 = USB-interface + demodulator + RF-tuner
  * IT9137 = IT9135 + MPEG TS input for connecting extra IT9133
 
 
  regards
  Antti
 
 
  The following changes since commit
  4ca286610f664acf3153634f3930acd2de993a9f:
 
 [media] radio-rtrack2: fix mute bug (2013-03-05 15:20:07 -0300)
 
  are available in the git repository at:
 
 git://linuxtv.org/anttip/media_tree.git it9135_tuner
 
  for you to fetch changes up to 17f64e21efadad3da1744feec97a12d97df15765:
 
 MAINTAINERS: add drivers/media/tuners/it913x* (2013-03-10 03:58:13
  +0200)
 
  
  Antti Palosaari (41):
 ITE IT913X silicon tuner driver
 af9033: support for it913x tuners
 af9035: add support for 1st gen it9135
 af9035: add auto configuration heuristic for it9135
 af9035: fix af9033 demod sampling frequency
 af9015: reject device TerraTec Cinergy T Stick Dual RC (rev. 2)
 af9035: [0ccd:0099] TerraTec Cinergy T Stick Dual RC (rev. 2)
 af9035: constify clock tables
 af9035: USB1.1 support (== PID filters)
 af9035: merge af9035 and it9135 eeprom read routines
 af9035: basic support for IT9135 v2 chips
 af9033: IT9135 v2 supported related changes
 af9035: IT9135 dual tuner related changes
 it913x: merge it913x_fe_start() to it913x_init_tuner()
 it913x: merge it913x_fe_suspend() to it913x_fe_sleep()
 it913x: rename functions and variables
 it913x: tuner power up routines
 it913x: get rid of it913x config struct
 it913x: remove unused variables
 it913x: include tuner IDs from af9033.h
 it913x: use dev_foo() logging
 af9033: add IT9135 demod reg init tables
 it913x: remove demod init reg tables
 af9035: select firmware loader according to firmware
 af9035: use already detected eeprom base addr
 af9035: set demod TS mode config in read_config()
 af9035: enable remote controller for IT9135 too
 af9035: change dual mode boolean to bit field
 af9033: add IT9135 tuner config 38 init table
 af9033: add IT9135 tuner config 51 init table
 af9033: add IT9135 tuner config 52 init table
 af9033: add IT9135 tuner config 60 init table
 af9033: add IT9135 tuner config 61 init table
 af9033: add IT9135 tuner config 62 init table
 it913x: remove unused af9033 demod tuner config inits
 af9033: move code from it913x to af9033
 af9033: sleep on attach()
 af9033: implement i/o optimized reg table writer
 af9035: check I/O errors on IR polling
 af9035: style changes for remote controller polling
 MAINTAINERS: add drivers/media/tuners/it913x*
 
MAINTAINERS   |   10 +
drivers/media/dvb-frontends/af9033.c  |  138 ++---
drivers/media/dvb-frontends/af9033.h  |   15 ++
drivers/media/dvb-frontends/af9033_priv.h | 1506
  +-
 
drivers/media/tuners/Kconfig  |7 +
drivers/media/tuners/Makefile |1 +
drivers/media/tuners/it913x.c |  447
  
drivers/media/tuners/it913x.h |   45 
drivers/media/tuners/it913x_priv.h|   78 +++
drivers/media/usb/dvb-usb-v2/Kconfig  |1 +
drivers/media/usb/dvb-usb-v2/af9015.c |   40 +++-
drivers/media/usb/dvb-usb-v2/af9035.c |  545
  -
drivers/media/usb/dvb-usb-v2/af9035.h |   47 +++--
13 files changed, 2654 insertions(+), 226 deletions(-)
create mode 100644 drivers/media/tuners/it913x.c
create mode 

Re: [PATCH v6 3/7] media: soc-camera: switch I2C subdevice drivers to use v4l2-clk

2013-03-18 Thread Sylwester Nawrocki

On 03/18/2013 11:23 AM, Hans Verkuil wrote:

On Mon March 18 2013 11:08:16 Guennadi Liakhovetski wrote:

On Mon, 18 Mar 2013, Hans Verkuil wrote:

On Fri March 15 2013 22:27:49 Guennadi Liakhovetski wrote:

[...]

@@ -431,6 +434,7 @@ static int imx074_probe(struct i2c_client *client,
struct imx074 *priv;
struct i2c_adapter *adapter = to_i2c_adapter(client-dev.parent);
struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
+   int ret;

if (!ssdd) {
dev_err(client-dev, IMX074: missing platform data!\n);
@@ -451,13 +455,23 @@ static int imx074_probe(struct i2c_client *client,

priv-fmt=imx074_colour_fmts[0];

-   return imx074_video_probe(client);
+   priv-clk = v4l2_clk_get(priv-subdev, mclk);
+   if (IS_ERR(priv-clk))
+   return PTR_ERR(priv-clk);
+
+   ret = imx074_video_probe(client);
+   if (ret  0)
+   v4l2_clk_put(priv-clk);
+


I feel uneasy about this. It's not the clock part as such but the fact that
assumptions are made about the usage of this sensor driver. It basically
comes down to the fact that these drivers are *still* tied to the soc-camera
framework. I think I am going to work on this in a few weeks time to cut
these drivers loose from soc-camera. We discussed how to do that in the past.


Sorry, not sure I understand. This is a generic (V4L2) clock, it has
nothing specific to soc-camera.


The assumption that there is a clock that needs to be set up is soc_camera
specific IMHO.


I don't think this is really soc-camera specific. This is specific to most
SoC camera subsystems, also those not using soc-camera framework (even 
though

there might be not that many of them ;)).


The whole point of the subdev API is to make drivers independent of bridge
drivers, and these soc-camera subdev drivers are the big exception and they
stick out like a sore thumb.


We are moving towards complete driver independency from the soc-camera
framework, and, afaics, there's not much left. Simply noone is interested
enough to do the work or to pay for it, noone has a really burning
use-case. And without one it's not very easy to implement things with no
test case. But sure, you're most welcome to work on this :)


I'll see what I can do since I am interested in doing this :-)


Anyway, w.r.t. the clock use: what happens if these drivers are used in e.g.
a USB webcam driver? In that case there probably won't be a clock involved
(well, there is one, but that is likely to be setup by the firmware/hardware
itself).


Well, from the sensor driver PoV if the sensor needs a clock it seems
logical for the driver to request it and to fail if it's not available.
USB cameras could provide a dummy clock, or we could implement one
centrally, however, this will lead to an undesirable result, that everyone
will just use that dummy clock... If we make clock support optional the
same thing will happen - noone will implement them. BTW, you're looking at
an intermediate patch in this series, which only adds clock support. In a
later patch the return error code for missing clock will be replaced with
-EPROBE_DEFER which serves as a sign, that no bridge driver is available
yes and _is_ required to support asynchronous probing.


Creating a dummy clock in a USB device would work, I agree.

Forget my other remarks: I hadn't realized that the global list of clocks
(clk_list) is unique per device (i2c adapter-i2c addr), so you can add
multiple clocks with the same name (mclk) and still match them to the correct
device.

That makes it all work as it should.

Regards,

Hans


Wouldn't it be better if the clock name is passed on through the platform data
(or device tree)? And if no clock name was specified, then there is no need to
get a clock either and the driver can assume that it will always have a clock.
That would solve this problem when this sensor driver is no longer soc-camera
dependent.


No. Yes, this has been discussed many times - in the context of the
generic clock API. I also proposed a patch, that did such a thing and was
kindly explained, why that wasn't a good idea :-) Clock names are names
of clock _inputs_ on the consumer. I.e. a sensor driver should request a
clock according to its datasheet. For the clock provider it's different,
say, a bridge driver cannot know what sensor will be connected to it and
clock it will be expecting. That's why we have clock lookup tables, that
connect physical clock objects (providers) with consumer clock names in
platform data (perhaps, a similar thing is done in DT, haven't looked
yet). I think, we could accept a compromise by using a common name for all
clocks with the same function. I'm using mclk as an abbreviation for
master clock.


I guess using a common mclk name would work. It's easy to specify this
in the device tree. In the clock consumer device's node an exact clock
name, according to the DT binding, can be specified in the 'clock-names'

Re: [REVIEWv2 PATCH 1/6] v4l2: add const to argument of write-only s_frequency ioctl.

2013-03-18 Thread Laurent Pinchart
Hi Hans,

Thanks for the patch.

On Monday 18 March 2013 15:12:00 Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 This ioctl is defined as IOW, so pass the argument as const.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---

[snip]

 diff --git a/drivers/media/radio/radio-keene.c
 b/drivers/media/radio/radio-keene.c index 296941a..a598852 100644
 --- a/drivers/media/radio/radio-keene.c
 +++ b/drivers/media/radio/radio-keene.c
 @@ -82,9 +82,12 @@ static inline struct keene_device *to_keene_dev(struct
 v4l2_device *v4l2_dev) /* Set frequency (if non-0), PA, mute and turn
 on/off the FM transmitter. */ static int keene_cmd_main(struct keene_device
 *radio, unsigned freq, bool play) {
 - unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
 + unsigned short freq_send;
   int ret;
 
 + if (freq)
 + freq = clamp(freq, FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL);
 + freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
   radio-buffer[0] = 0x00;
   radio-buffer[1] = 0x50;
   radio-buffer[2] = (freq_send  8)  0xff;
 @@ -215,15 +218,15 @@ static int vidioc_s_modulator(struct file *file, void
 *priv, }
 
  static int vidioc_s_frequency(struct file *file, void *priv,
 - struct v4l2_frequency *f)
 + const struct v4l2_frequency *f)
  {
   struct keene_device *radio = video_drvdata(file);
 
   if (f-tuner != 0 || f-type != V4L2_TUNER_RADIO)
   return -EINVAL;
 - f-frequency = clamp(f-frequency,
 - FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL);
 - return keene_cmd_main(radio, f-frequency, true);
 + /* Take care: keene_cmd_main handles a frequency of 0 as a
 +  * special case, so make sure we never give that from here. */
 + return keene_cmd_main(radio, f-frequency ? f-frequency : 1, true);

Can't you keep the clamp() here ? That looks easier.

  }
 
  static int vidioc_g_frequency(struct file *file, void *priv,

-- 
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: [REVIEWv2 PATCH 4/6] v4l2: add const to argument of write-only s_register ioctl.

2013-03-18 Thread Laurent Pinchart
Hi Hans,

Thanks for the patch.

On Monday 18 March 2013 15:12:03 Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 This ioctl is defined as IOW, so pass the argument as const.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 Acked-by: Lad, Prabhakar prabhakar.cse...@gmail.com

[snip]

 diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c
 b/drivers/media/pci/ivtv/ivtv-ioctl.c index 080f179..15e08aa 100644
 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c
 +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
 @@ -711,49 +711,50 @@ static int ivtv_g_chip_ident(struct file *file, void
 *fh, struct v4l2_dbg_chip_i }
 
  #ifdef CONFIG_VIDEO_ADV_DEBUG
 -static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
 +static volatile u8 __iomem *ivtv_itvc_start(struct ivtv *itv,
 + const struct v4l2_dbg_register *regs)

I haven't changed my mind since v1, I still don't think you need a volatile 
here :-)

  {
 - struct v4l2_dbg_register *regs = arg;
 - volatile u8 __iomem *reg_start;
 -
 - if (!capable(CAP_SYS_ADMIN))
 - return -EPERM;
   if (regs-reg = IVTV_REG_OFFSET  regs-reg  IVTV_REG_OFFSET +
 IVTV_REG_SIZE) -  reg_start = itv-reg_mem - IVTV_REG_OFFSET;
 - else if (itv-has_cx23415  regs-reg = IVTV_DECODER_OFFSET 
 + return itv-reg_mem - IVTV_REG_OFFSET;
 + if (itv-has_cx23415  regs-reg = IVTV_DECODER_OFFSET 
   regs-reg  IVTV_DECODER_OFFSET + IVTV_DECODER_SIZE)
 - reg_start = itv-dec_mem - IVTV_DECODER_OFFSET;
 - else if (regs-reg  IVTV_ENCODER_SIZE)
 - reg_start = itv-enc_mem;
 - else
 - return -EINVAL;
 -
 - regs-size = 4;
 - if (cmd == VIDIOC_DBG_G_REGISTER)
 - regs-val = readl(regs-reg + reg_start);
 - else
 - writel(regs-val, regs-reg + reg_start);
 - return 0;
 + return itv-dec_mem - IVTV_DECODER_OFFSET;
 + if (regs-reg  IVTV_ENCODER_SIZE)
 + return itv-enc_mem;
 + return NULL;
  }
 
  static int ivtv_g_register(struct file *file, void *fh, struct
 v4l2_dbg_register *reg) {
   struct ivtv *itv = fh2id(fh)-itv;
 
 - if (v4l2_chip_match_host(reg-match))
 - return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg);
 + if (v4l2_chip_match_host(reg-match)) {
 + volatile u8 __iomem *reg_start = ivtv_itvc_start(itv, reg);
 +
 + if (reg_start == NULL)
 + return -EINVAL;
 + reg-size = 4;
 + reg-val = readl(reg-reg + reg_start);
 + return 0;
 + }
   /* TODO: subdev errors should not be ignored, this should become a
  subdev helper function. */
   ivtv_call_all(itv, core, g_register, reg);
   return 0;
  }
 
 -static int ivtv_s_register(struct file *file, void *fh, struct
 v4l2_dbg_register *reg) +static int ivtv_s_register(struct file *file, void
 *fh, const struct v4l2_dbg_register *reg) {
   struct ivtv *itv = fh2id(fh)-itv;
 
 - if (v4l2_chip_match_host(reg-match))
 - return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg);
 + if (v4l2_chip_match_host(reg-match)) {
 + volatile u8 __iomem *reg_start = ivtv_itvc_start(itv, reg);
 +
 + if (reg_start == NULL)
 + return -EINVAL;
 + writel(reg-val, reg-reg + reg_start);
 + return 0;
 + }
   /* TODO: subdev errors should not be ignored, this should become a
  subdev helper function. */
   ivtv_call_all(itv, core, s_register, reg);

-- 
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: [PATCH 2/2] dvb_frontend: Simplify the emulation logic

2013-03-18 Thread Mauro Carvalho Chehab
Em Mon, 18 Mar 2013 17:05:12 -0300
Fabio Estevam feste...@gmail.com escreveu:

 Hi Mauro,
 
 On Mon, Mar 18, 2013 at 4:25 PM, Mauro Carvalho Chehab
 mche...@redhat.com wrote:
 
  -static int emulate_delivery_system(struct dvb_frontend *fe,
  -  enum dvbv3_emulation_type type,
  -  u32 delsys, u32 desired_system)
  +/**
  + * emulate_delivery_system - emulate a DVBv5 delivery system with a DVBv3 
  type
  + * @fe:struct frontend;
  + * @desired_system:DVBv5 type that will be used for emulation
 
 'desired_system' parameter has been removed in this patch. 'delsys'
 should be put in the description instead.

Thanks for reviewing it!

Yeah, internally I made several versions of this patch, in order to make
each routine clear. On the very last minute, I ended by just removing
desired_system, keeping just one parameter there after fe.

I'm changing it at the version I'm committing.

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


Re: [PATCH RFC] [media] add Aptina mt9m114 HD digital image sensor driver

2013-03-18 Thread Mauro Carvalho Chehab
Hi Scott,

Em Fri, 18 Jan 2013 17:00:44 -0500
Scott Jiang scott.jiang.li...@gmail.com escreveu:

 This driver support parallel data output mode and
 QVGA/VGA/WVGA/720P resolution. You can select YCbCr and RGB565
 output format.
 

There are a few checkpatch warnings, due to recent API changes at
the Kernel:

WARNING: Using __devinit is unnecessary
#987: FILE: drivers/media/i2c/mt9m114.c:923:
+static int __devinit mt9m114_probe(struct i2c_client *client,

WARNING: Using __devexit is unnecessary
#1087: FILE: drivers/media/i2c/mt9m114.c:1023:
+static int __devexit mt9m114_remove(struct i2c_client *client)


While checkpatch didn't complain, of course you'll need to remove
the __devexit_p() macro usage here:
+   .remove = __devexit_p(mt9m114_remove),

Please fix those.

Thanks!
Mauro

 Signed-off-by: Scott Jiang scott.jiang.li...@gmail.com
 ---
  drivers/media/i2c/Kconfig   |   10 +
  drivers/media/i2c/Makefile  |1 +
  drivers/media/i2c/mt9m114.c | 1055 
 +++
  3 files changed, 1066 insertions(+), 0 deletions(-)
  create mode 100644 drivers/media/i2c/mt9m114.c
 
 diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
 index 1e4b2d0..5705f4a 100644
 --- a/drivers/media/i2c/Kconfig
 +++ b/drivers/media/i2c/Kconfig
 @@ -432,6 +432,16 @@ config VIDEO_VS6624
 To compile this driver as a module, choose M here: the
 module will be called vs6624.
  
 +config VIDEO_MT9M114
 + tristate Aptina MT9M114 sensor support
 + depends on VIDEO_V4L2  I2C
 + ---help---
 +   This is a Video4Linux2 sensor-level driver for the Aptina MT9M114
 +   camera.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called mt9m114.
 +
  config VIDEO_MT9M032
   tristate MT9M032 camera sensor support
   depends on I2C  VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API
 diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
 index b1d62df..bd71968 100644
 --- a/drivers/media/i2c/Makefile
 +++ b/drivers/media/i2c/Makefile
 @@ -50,6 +50,7 @@ obj-$(CONFIG_VIDEO_OV7670)  += ov7670.o
  obj-$(CONFIG_VIDEO_TCM825X) += tcm825x.o
  obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
  obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o
 +obj-$(CONFIG_VIDEO_MT9M114) += mt9m114.o
  obj-$(CONFIG_VIDEO_MT9P031) += mt9p031.o
  obj-$(CONFIG_VIDEO_MT9T001) += mt9t001.o
  obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o
 diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
 new file mode 100644
 index 000..564b711
 --- /dev/null
 +++ b/drivers/media/i2c/mt9m114.c
 @@ -0,0 +1,1055 @@
 +/*
 + * mt9m114.c Aptina MT9M114 sensor driver
 + *
 + * Copyright (c) 2012 Analog Devices Inc.
 + *
 + * refer to: SoC Camera driver by Andrew Chew ac...@nvidia.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 + */
 +
 +#include linux/delay.h
 +#include linux/errno.h
 +#include linux/i2c.h
 +#include linux/init.h
 +#include linux/module.h
 +#include linux/slab.h
 +#include linux/types.h
 +#include linux/videodev2.h
 +
 +#include media/v4l2-chip-ident.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-device.h
 +#include media/v4l2-mediabus.h
 +
 +/* Sysctl registers */
 +#define MT9M114_CHIP_ID  0x
 +#define MT9M114_COMMAND_REGISTER 0x0080
 +#define MT9M114_COMMAND_REGISTER_APPLY_PATCH (1  0)
 +#define MT9M114_COMMAND_REGISTER_SET_STATE   (1  1)
 +#define MT9M114_COMMAND_REGISTER_REFRESH (1  2)
 +#define MT9M114_COMMAND_REGISTER_WAIT_FOR_EVENT  (1  3)
 +#define MT9M114_COMMAND_REGISTER_OK  (1  15)
 +#define MT9M114_SOFT_RESET   0x001a
 +#define MT9M114_PAD_SLEW 0x001e
 +#define MT9M114_PAD_CONTROL  0x0032
 +
 +/* XDMA registers */
 +#define MT9M114_ACCESS_CTL_STAT  0x0982
 +#define MT9M114_PHYSICAL_ADDRESS_ACCESS  0x098a
 +#define MT9M114_LOGICAL_ADDRESS_ACCESS   0x098e
 +
 +/* Core registers */
 +#define MT9M114_RESET_REGISTER   0x301a
 +#define MT9M114_FLASH0x3046
 +#define MT9M114_CUSTOMER_REV 0x31fe
 +
 +/* Camera Control registers */
 +#define MT9M114_CAM_SENSOR_CFG_Y_ADDR_START  

Re: Fw: [patch 02/03 v2] usb hid quirks for Masterkit MA901 usb radio

2013-03-18 Thread Alexey Klimov
On Mon, Mar 18, 2013 at 5:51 PM, Jiri Kosina jkos...@suse.cz wrote:
 On Fri, 15 Mar 2013, Alexey Klimov wrote:

  indeed your patch breaks Atmega applications which using V-USB
  (http://www.obdev.at/products/vusb/index.html), because 0x16c0, 0x05df are
  the default Ids of V-USB.
 
  Have a look at this FAQ
 
  https://github.com/obdev/v-usb/blob/master/usbdrv/USB-ID-FAQ.txt
 
  It seems that the Masterkit M901 also uses V-USB.
 
  I'm using an IR remote control receiver based on Atmega8 with V-USB. Since
  Kernel 3.8.2 there is no more hidraw device for my receiver, so I had to
  change the Device-ID to 0x27d9. I think there are a lot of other V-USB
  applications with similar problems.
 
  Dirk

 Exactly. That's why i tried to point it out. Thanks for explaining
 this in simplier words.

 It's difficult to answer on top posting emails.

 I don't understand one thing about your letter. Did you put
 linux-media kernel list in bcc (hide copy)? Is there any reason for
 this? http://www.mail-archive.com/linux-media@vger.kernel.org/msg59714.html

 Mauro, Jiri,
 can we revert this patch? If you need any ack or sign from me i'm
 ready to send it.

 I can contact people who cares about stable trees and ask them to
 revert this patch from stable trees.

 During 3.9-rcX cycle i can try to figure out some fix or additional
 checks for radio-ma901.c driver.

 I can revert 0322bd3980 and push it out to Linus for 3.9 still, Ccing
 stable.

 Or Mauro, as the original patch went in through your tree, are you
 handling that?

I think we really need to revert it before final release. It's already -rc3.

 Also additional work will be needed later to properly detect the
 underlying device ... the best thing to do here is to put an entry into
 hid_ignore(), similar to what we do for example for Keene FM vs. Logitech
 AudioHub.

Yes, i just checked how hid_ignore() works and prepared dirty fix to
test in almost the same way like it's done for Keene usb driver. I
will send correct fix in next few days.

Thanks.
Best regards, Klimov Alexey
--
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/3] dma-buf: restore args on failure of dma_buf_mmap

2013-03-18 Thread Mauro Carvalho Chehab
Em Thu, 07 Feb 2013 15:54:52 +0530
Sumit Semwal sumit.sem...@linaro.org escreveu:

 Hi John,
 
 On Thursday 07 February 2013 05:33 AM, John Sheu wrote:
  From: John Sheu s...@chromium.org
 
  Callers to dma_buf_mmap expect to fput() the vma struct's vm_file
  themselves on failure.  Not restoring the struct's data on failure
  causes a double-decrement of the vm_file's refcount.
 Thanks for your patch; could you please re-send it to the correct, 
 relevant lists and me (as the maintainer of dma-buf) rather than just to 
 linux-media ml?

Yes, it doesn't make sense to apply this one via the media tree ;)

I'm applying patches 1 and 2, as they should go through the media tree.

Thanks!
Mauro
 
 I just chanced to see this patch, otherwise it could easily have slipped 
 past me (and other interested parties).
 
 You could run scripts/get_maintainer.pl on your patch to find out the 
 right lists / email IDs to CC.
 
 Thanks and best regards,
 ~Sumit.
 
  Signed-off-by: John Sheu s...@google.com
  ---
drivers/base/dma-buf.c | 18 ++
1 file changed, 14 insertions(+), 4 deletions(-)
 
  diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
  index a3f79c4..01daf9c 100644
  --- a/drivers/base/dma-buf.c
  +++ b/drivers/base/dma-buf.c
  @@ -446,6 +446,9 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap);
int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
   unsigned long pgoff)
{
  +   struct file *oldfile;
  +   int ret;
  +
  if (WARN_ON(!dmabuf || !vma))
  return -EINVAL;
 
  @@ -459,14 +462,21 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct 
  vm_area_struct *vma,
  return -EINVAL;
 
  /* readjust the vma */
  -   if (vma-vm_file)
  -   fput(vma-vm_file);
  -
  +   oldfile = vma-vm_file;
  vma-vm_file = get_file(dmabuf-file);
 
  vma-vm_pgoff = pgoff;
 
  -   return dmabuf-ops-mmap(dmabuf, vma);
  +   ret = dmabuf-ops-mmap(dmabuf, vma);
  +   if (ret) {
  +   /* restore old parameters on failure */
  +   vma-vm_file = oldfile;
  +   fput(dmabuf-file);
  +   } else {
  +   if (oldfile)
  +   fput(oldfile);
  +   }
  +   return ret;
}
EXPORT_SYMBOL_GPL(dma_buf_mmap);
 
 
 
 --
 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


-- 

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


Re: [PATCH] [media] ir: IR_RX51 only works on OMAP2

2013-03-18 Thread Mauro Carvalho Chehab
Em Thu, 14 Mar 2013 22:56:44 +0100
Arnd Bergmann a...@arndb.de escreveu:

 This driver can be enabled on OMAP1 at the moment, which breaks
 allyesconfig for that platform. Let's mark it OMAP2PLUS-only
 in Kconfig, since that is the only thing it builds on.
 
 Signed-off-by: Arnd Bergmann a...@arndb.de
 Cc: Mauro Carvalho Chehab mche...@redhat.com
 Cc: Timo Kokkonen timo.t.kokko...@iki.fi
 Cc: Tony Lindgren t...@atomide.com
 Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
 Cc: linux-media@vger.kernel.org
 ---
 Mauro, please apply for 3.9

OK, I'm applying it on my 3.9 branch right now.

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


Re: [PATCH v6 7/7] ARM: shmobile: convert ap4evb to asynchronously register camera subdevices

2013-03-18 Thread Simon Horman
On Fri, Mar 15, 2013 at 10:27:53PM +0100, Guennadi Liakhovetski wrote:
 Register the imx074 camera I2C and the CSI-2 platform devices directly
 in board platform data instead of letting the sh_mobile_ceu_camera driver
 and the soc-camera framework register them at their run-time. This uses
 the V4L2 asynchronous subdevice probing capability.
 
 Signed-off-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
 ---
 
 v6: no change
 
  arch/arm/mach-shmobile/board-ap4evb.c |  103 +++-
  arch/arm/mach-shmobile/clock-sh7372.c |1 +
  2 files changed, 62 insertions(+), 42 deletions(-)
 
 diff --git a/arch/arm/mach-shmobile/board-ap4evb.c 
 b/arch/arm/mach-shmobile/board-ap4evb.c
 index 38f1259..450e06b 100644
 --- a/arch/arm/mach-shmobile/board-ap4evb.c
 +++ b/arch/arm/mach-shmobile/board-ap4evb.c
 @@ -50,6 +50,7 @@
  #include media/sh_mobile_ceu.h
  #include media/sh_mobile_csi2.h
  #include media/soc_camera.h
 +#include media/v4l2-async.h
  
  #include sound/sh_fsi.h
  #include sound/simple_card.h
 @@ -871,22 +872,32 @@ static struct platform_device leds_device = {
   },
  };
  
 -static struct i2c_board_info imx074_info = {
 - I2C_BOARD_INFO(imx074, 0x1a),
 +/* I2C */
 +static struct soc_camera_subdev_desc imx074_desc;
 +static struct i2c_board_info i2c0_devices[] = {
 + {
 + I2C_BOARD_INFO(ak4643, 0x13),
 + }, {
 + I2C_BOARD_INFO(imx074, 0x1a),
 + .platform_data = imx074_desc,
 + },
  };
  
 -static struct soc_camera_link imx074_link = {
 - .bus_id = 0,
 - .board_info = imx074_info,
 - .i2c_adapter_id = 0,
 - .module_name= imx074,
 +static struct i2c_board_info i2c1_devices[] = {
 + {
 + I2C_BOARD_INFO(r2025sd, 0x32),
 + },
  };
  
 -static struct platform_device ap4evb_camera = {
 - .name   = soc-camera-pdrv,
 - .id = 0,
 - .dev= {
 - .platform_data = imx074_link,
 +static struct resource csi2_resources[] = {
 + {
 + .name   = CSI2,
 + .start  = 0xffc9,
 + .end= 0xffc90fff,
 + .flags  = IORESOURCE_MEM,
 + }, {
 + .start  = intcs_evt2irq(0x17a0),
 + .flags  = IORESOURCE_IRQ,
   },
  };
  
 @@ -895,7 +906,7 @@ static struct sh_csi2_client_config csi2_clients[] = {
   .phy= SH_CSI2_PHY_MAIN,
   .lanes  = 0,/* default: 2 lanes */
   .channel= 0,
 - .pdev   = ap4evb_camera,
 + .name   = imx074,
   },
  };
  
 @@ -906,31 +917,50 @@ static struct sh_csi2_pdata csi2_info = {
   .flags  = SH_CSI2_ECC | SH_CSI2_CRC,
  };
  
 -static struct resource csi2_resources[] = {
 - [0] = {
 - .name   = CSI2,
 - .start  = 0xffc9,
 - .end= 0xffc90fff,
 - .flags  = IORESOURCE_MEM,
 +static struct platform_device csi2_device = {
 + .name   = sh-mobile-csi2,
 + .id = 0,

Is it more appropriate to use id = -1 here?
I am entirely unsure.

 + .num_resources  = ARRAY_SIZE(csi2_resources),
 + .resource   = csi2_resources,
 + .dev= {
 + .platform_data = csi2_info,
   },
 - [1] = {
 - .start  = intcs_evt2irq(0x17a0),
 - .flags  = IORESOURCE_IRQ,
 +};
 +
 +static struct soc_camera_async_subdev csi2_sd = {
 + .asd.hw = {
 + .bus_type = V4L2_ASYNC_BUS_PLATFORM,
 + .match.platform.name = sh-mobile-csi2.0,
   },
 + .role = SOCAM_SUBDEV_DATA_PROCESSOR,
  };
  
 -static struct sh_mobile_ceu_companion csi2 = {
 - .id = 0,
 - .num_resources  = ARRAY_SIZE(csi2_resources),
 - .resource   = csi2_resources,
 - .platform_data  = csi2_info,
 +static struct soc_camera_async_subdev imx074_sd = {
 + .asd.hw = {
 + .bus_type = V4L2_ASYNC_BUS_I2C,
 + .match.i2c = {
 + .adapter_id = 0,
 + .address = 0x1a,
 + },
 + },
 + .role = SOCAM_SUBDEV_DATA_SOURCE,
  };
  
 +static struct v4l2_async_subdev *ceu_subdevs[] = {
 + /* Single 2-element group */
 + csi2_sd.asd,
 + imx074_sd.asd,
 +};
 +
 +/* 0-terminated array of group-sizes */
 +static int ceu_subdev_sizes[] = {ARRAY_SIZE(ceu_subdevs), 0};
 +
  static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
   .flags = SH_CEU_FLAG_USE_8BIT_BUS,
   .max_width = 8188,
   .max_height = 8188,
 - .csi2 = csi2,
 + .asd = ceu_subdevs,
 + .asd_sizes = ceu_subdev_sizes,
  };
  
  static struct resource ceu_resources[] = {
 @@ -975,7 +1005,7 @@ static struct platform_device *ap4evb_devices[] 
 __initdata = {
   lcdc_device,
   lcdc1_device,
   ceu_device,
 - ap4evb_camera,
 + csi2_device,
   meram_device,
  };
  
 @@ -1070,19 +1100,6 @@ static struct i2c_board_info