summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/cx231xx/cx231xx-video.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/video/cx231xx/cx231xx-video.c')
-rw-r--r--linux/drivers/media/video/cx231xx/cx231xx-video.c119
1 files changed, 54 insertions, 65 deletions
diff --git a/linux/drivers/media/video/cx231xx/cx231xx-video.c b/linux/drivers/media/video/cx231xx/cx231xx-video.c
index 2dbe65b83..d53ddcb6a 100644
--- a/linux/drivers/media/video/cx231xx/cx231xx-video.c
+++ b/linux/drivers/media/video/cx231xx/cx231xx-video.c
@@ -44,6 +44,8 @@
#include "cx231xx.h"
#include "cx231xx-vbi.h"
+#define CX231XX_VERSION_CODE KERNEL_VERSION(0, 0, 1)
+
#define DRIVER_AUTHOR "Srinivasa Deevi <srinivasa.deevi@conexant.com>"
#define DRIVER_DESC "Conexant cx231xx based USB video device driver"
@@ -702,7 +704,7 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
f.frequency = dev->ctl_freq;
f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f);
+ call_all(dev, tuner, s_frequency, &f);
return 0;
}
@@ -828,8 +830,7 @@ void video_mux(struct cx231xx *dev, int index)
cx231xx_set_video_input_mux(dev, index);
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_INT_S_VIDEO_ROUTING,
- &route);
+ cx25840_call(dev, video, s_routing, &route);
cx231xx_set_audio_input(dev, dev->ctl_ainput);
@@ -1043,7 +1044,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
dev->format = fmt;
get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_S_FMT, f);
+ call_all(dev, video, s_fmt, f);
/* Set the correct alternate setting for this resolution */
cx231xx_resolution_set(dev);
@@ -1062,7 +1063,7 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id * id)
return 0;
}
-static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm)
+static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm)
{
struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev;
@@ -1088,7 +1089,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm)
dev->height = f.fmt.pix.height;
get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_S_STD, &dev->norm);
+ call_all(dev, tuner, s_std, dev->norm);
mutex_unlock(&dev->lock);
@@ -1242,7 +1243,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
*qc = cx231xx_ctls[i].v;
mutex_lock(&dev->lock);
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_QUERYCTRL, qc);
+ call_all(dev, core, queryctrl, qc);
mutex_unlock(&dev->lock);
if (qc->type)
@@ -1263,9 +1264,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
return rc;
mutex_lock(&dev->lock);
-
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_G_CTRL, ctrl);
-
+ call_all(dev, core, g_ctrl, ctrl);
mutex_unlock(&dev->lock);
return rc;
}
@@ -1282,9 +1281,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
return rc;
mutex_lock(&dev->lock);
-
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_S_CTRL, ctrl);
-
+ call_all(dev, core, s_ctrl, ctrl);
mutex_unlock(&dev->lock);
return rc;
}
@@ -1326,9 +1323,7 @@ static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
return -EINVAL;
#if 0 /* Keep */
mutex_lock(&dev->lock);
-
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_TUNER, t);
-
+ call_all(dev, tuner, s_tuner, t);
mutex_unlock(&dev->lock);
#endif
return 0;
@@ -1344,7 +1339,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
f->frequency = dev->ctl_freq;
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_G_FREQUENCY, f);
+ call_all(dev, tuner, g_frequency, f);
mutex_unlock(&dev->lock);
@@ -1380,10 +1375,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
if (dev->tuner_type == TUNER_XC5000) {
if (dev->cx231xx_set_analog_freq != NULL)
dev->cx231xx_set_analog_freq(dev, f->frequency);
- } else {
- cx231xx_i2c_call_clients(&dev->i2c_bus[1],
- VIDIOC_S_FREQUENCY, f);
- }
+ } else
+ call_all(dev, tuner, s_frequency, f);
mutex_unlock(&dev->lock);
@@ -1428,36 +1421,36 @@ static int vidioc_g_register(struct file *file, void *priv,
reg->val = value[0] | value[1] << 8 |
value[2] << 16 | value[3] << 24;
break;
- case 1: /* Colibri - read byte */
- ret = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
+ case 1: /* AFE - read byte */
+ ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS,
(u16)reg->reg, 2, &data, 1);
reg->val = le32_to_cpu(data & 0xff);
break;
- case 14: /* Colibri - read dword */
- ret = cx231xx_read_i2c_data(dev, Colibri_DEVICE_ADDRESS,
+ case 14: /* AFE - read dword */
+ ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS,
(u16)reg->reg, 2, &data, 4);
reg->val = le32_to_cpu(data);
break;
- case 2: /* Hammerhead - read byte */
- ret = cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
+ case 2: /* Video Block - read byte */
+ ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS,
(u16)reg->reg, 2, &data, 1);
reg->val = le32_to_cpu(data & 0xff);
break;
- case 24: /* Hammerhead - read dword */
- ret = cx231xx_read_i2c_data(dev, HAMMERHEAD_I2C_ADDRESS,
+ case 24: /* Video Block - read dword */
+ ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS,
(u16)reg->reg, 2, &data, 4);
reg->val = le32_to_cpu(data);
break;
- case 3: /* flatiron - read byte */
+ case 3: /* I2S block - read byte */
ret = cx231xx_read_i2c_data(dev,
- Flatrion_DEVICE_ADDRESS,
+ I2S_BLK_DEVICE_ADDRESS,
(u16)reg->reg, 1,
&data, 1);
reg->val = le32_to_cpu(data & 0xff);
break;
- case 34: /* flatiron - read dword */
+ case 34: /* I2S Block - read dword */
ret =
- cx231xx_read_i2c_data(dev, Flatrion_DEVICE_ADDRESS,
+ cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS,
(u16)reg->reg, 1, &data, 4);
reg->val = le32_to_cpu(data);
break;
@@ -1465,8 +1458,7 @@ static int vidioc_g_register(struct file *file, void *priv,
return ret < 0 ? ret : 0;
case V4L2_CHIP_MATCH_I2C_DRIVER:
- cx231xx_i2c_call_clients(&dev->i2c_bus[0],
- VIDIOC_DBG_G_REGISTER, reg);
+ call_all(dev, core, g_register, reg);
return 0;
case V4L2_CHIP_MATCH_I2C_ADDR:
/* Not supported yet */
@@ -1477,7 +1469,7 @@ static int vidioc_g_register(struct file *file, void *priv,
}
mutex_lock(&dev->lock);
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_G_REGISTER, reg);
+ call_all(dev, core, g_register, reg);
mutex_unlock(&dev->lock);
return ret;
@@ -1511,43 +1503,43 @@ static int vidioc_s_register(struct file *file, void *priv,
(u16)reg->reg, data,
4);
break;
- case 1: /* Colibri - read byte */
+ case 1: /* AFE - read byte */
ret = cx231xx_write_i2c_data(dev,
- Colibri_DEVICE_ADDRESS,
+ AFE_DEVICE_ADDRESS,
(u16)reg->reg, 2,
value, 1);
break;
- case 14: /* Colibri - read dword */
+ case 14: /* AFE - read dword */
ret = cx231xx_write_i2c_data(dev,
- Colibri_DEVICE_ADDRESS,
+ AFE_DEVICE_ADDRESS,
(u16)reg->reg, 2,
value, 4);
break;
- case 2: /* Hammerhead - read byte */
+ case 2: /* Video Block - read byte */
ret =
cx231xx_write_i2c_data(dev,
- HAMMERHEAD_I2C_ADDRESS,
+ VID_BLK_I2C_ADDRESS,
(u16)reg->reg, 2,
value, 1);
break;
- case 24: /* Hammerhead - read dword */
+ case 24: /* Video Block - read dword */
ret =
cx231xx_write_i2c_data(dev,
- HAMMERHEAD_I2C_ADDRESS,
+ VID_BLK_I2C_ADDRESS,
(u16)reg->reg, 2,
value, 4);
break;
- case 3: /* flatiron - read byte */
+ case 3: /* I2S block - read byte */
ret =
cx231xx_write_i2c_data(dev,
- Flatrion_DEVICE_ADDRESS,
+ I2S_BLK_DEVICE_ADDRESS,
(u16)reg->reg, 1,
value, 1);
break;
- case 34: /* flatiron - read dword */
+ case 34: /* I2S block - read dword */
ret =
cx231xx_write_i2c_data(dev,
- Flatrion_DEVICE_ADDRESS,
+ I2S_BLK_DEVICE_ADDRESS,
(u16)reg->reg, 1,
value, 4);
break;
@@ -1560,9 +1552,7 @@ static int vidioc_s_register(struct file *file, void *priv,
}
mutex_lock(&dev->lock);
-
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_S_REGISTER, reg);
-
+ call_all(dev, core, s_register, reg);
mutex_unlock(&dev->lock);
return ret;
@@ -1606,6 +1596,8 @@ static int vidioc_streamon(struct file *file, void *priv,
if (likely(rc >= 0))
rc = videobuf_streamon(&fh->vb_vidq);
+ call_all(dev, video, s_stream, 1);
+
mutex_unlock(&dev->lock);
return rc;
@@ -1622,7 +1614,7 @@ static int vidioc_streamoff(struct file *file, void *priv,
if (rc < 0)
return rc;
- if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
+ if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
(fh->type != V4L2_BUF_TYPE_VBI_CAPTURE))
return -EINVAL;
if (type != fh->type)
@@ -1630,6 +1622,8 @@ static int vidioc_streamoff(struct file *file, void *priv,
mutex_lock(&dev->lock);
+ cx25840_call(dev, video, s_stream, 0);
+
videobuf_streamoff(&fh->vb_vidq);
res_free(fh);
@@ -1646,8 +1640,7 @@ static int vidioc_querycap(struct file *file, void *priv,
strlcpy(cap->driver, "cx231xx", sizeof(cap->driver));
strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card));
- strlcpy(cap->bus_info, dev_name(&dev->udev->dev),
- sizeof(cap->bus_info));
+ usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
cap->version = CX231XX_VERSION_CODE;
@@ -1694,7 +1687,7 @@ static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv,
f->fmt.sliced.service_set = 0;
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_G_FMT, f);
+ call_all(dev, video, g_fmt, f);
if (f->fmt.sliced.service_set == 0)
rc = -EINVAL;
@@ -1715,7 +1708,7 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv,
return rc;
mutex_lock(&dev->lock);
- cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_G_FMT, f);
+ call_all(dev, video, g_fmt, f);
mutex_unlock(&dev->lock);
if (f->fmt.sliced.service_set == 0)
@@ -1870,7 +1863,7 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
t->type = V4L2_TUNER_RADIO;
mutex_lock(&dev->lock);
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t);
+ call_all(dev, tuner, s_tuner, t);
mutex_unlock(&dev->lock);
return 0;
@@ -1903,7 +1896,7 @@ static int radio_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
return -EINVAL;
mutex_lock(&dev->lock);
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_TUNER, t);
+ call_all(dev, tuner, s_tuner, t);
mutex_unlock(&dev->lock);
return 0;
@@ -2009,8 +2002,7 @@ static int cx231xx_v4l2_open(struct file *filp)
/* cx231xx_start_radio(dev); */
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], AUDC_SET_RADIO,
- NULL);
+ call_all(dev, tuner, s_radio);
}
dev->users++;
@@ -2133,8 +2125,7 @@ static int cx231xx_v4l2_close(struct file *filp)
}
/* Save some power by putting tuner to sleep */
- cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_STANDBY,
- NULL);
+ call_all(dev, core, s_standby, 0);
/* do this before setting alternate! */
cx231xx_uninit_isoc(dev);
@@ -2348,7 +2339,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev,
*vfd = *template;
vfd->minor = -1;
- vfd->parent = &dev->udev->dev;
+ vfd->v4l2_dev = &dev->v4l2_dev;
vfd->release = video_device_release;
vfd->debug = video_debug;
@@ -2361,8 +2352,6 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
{
int ret;
- cx231xx_info("%s()\n", __func__);
-
cx231xx_info("%s: v4l2 driver version %d.%d.%d\n",
dev->name,
(CX231XX_VERSION_CODE >> 16) & 0xff,