Skip to content

Commit

Permalink
Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
Browse files Browse the repository at this point in the history
* master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb:
  V4L/DVB (5305): Mark VIDIOC_DBG_S/G_REGISTER as experimental
  V4L/DVB (5271): Add VIDIOC_TRY_ENCODER_CMD and VIDIOC_ENCODER_CMD ioctls.
  V4L/DVB (5270): Add VIDIOC_G_ENC_INDEX ioctl
  V4L/DVB (5276): Cxusb: fix firmware patch for big endian systems
  V4L/DVB (5258): Cafe_ccic: fix compiler warning
  V4L/DVB (5295): Digitv: open nxt6000 i2c_gate for TDED4 tuner handling
  V4L/DVB (5304): Improve chip matching in v4l2_register
  V4L/DVB (5255): Fix cx25840 firmware loading.
  • Loading branch information
Linus Torvalds committed Mar 2, 2007
2 parents d701d8a + f3502b8 commit 100b425
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 38 deletions.
4 changes: 2 additions & 2 deletions drivers/media/dvb/dvb-usb/cxusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@ static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {

fw->data[BLUEBIRD_01_ID_OFFSET + 2] =
udev->descriptor.idProduct + 1;
le16_to_cpu(udev->descriptor.idProduct) + 1;
fw->data[BLUEBIRD_01_ID_OFFSET + 3] =
udev->descriptor.idProduct >> 8;
le16_to_cpu(udev->descriptor.idProduct) >> 8;

return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/media/dvb/dvb-usb/digitv.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe, struct dvb_f
struct dvb_usb_adapter *adap = fe->dvb->priv;
u8 b[5];
dvb_usb_tuner_calc_regs(fe,fep,b, 5);
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
return digitv_ctrl_msg(adap->dev, USB_WRITE_TUNER, 0, &b[1], 4, NULL, 0);
}

Expand Down
4 changes: 1 addition & 3 deletions drivers/media/video/cafe_ccic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ static ssize_t cafe_v4l_read(struct file *filp,
char __user *buffer, size_t len, loff_t *pos)
{
struct cafe_camera *cam = filp->private_data;
int ret;
int ret = 0;

/*
* Perhaps we're in speculative read mode and already
Expand Down Expand Up @@ -1251,8 +1251,6 @@ static int cafe_vidioc_reqbufs(struct file *filp, void *priv,

if (cam->n_sbufs == 0) /* no luck at all - ret already set */
kfree(cam->sb_bufs);
else
ret = 0;
req->count = cam->n_sbufs; /* In case of partial success */

out:
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/video/cx25840/cx25840-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
{
struct v4l2_register *reg = arg;

if (reg->i2c_id != I2C_DRIVERID_CX25840)
if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Expand Down Expand Up @@ -903,13 +903,13 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
state->vbi_line_offset = 8;
state->id = id;

i2c_attach_client(client);

if (state->is_cx25836)
cx25836_initialize(client);
else
cx25840_initialize(client, 1);

i2c_attach_client(client);

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/cx25840/cx25840-firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
#define FWSEND 48

#define FWDEV(x) &((x)->adapter->dev)
#define FWDEV(x) &((x)->dev)

static char *firmware = FWFILE;

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/cx88/cx88-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ static int vidioc_g_register (struct file *file, void *fh,
{
struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core;

if (reg->i2c_id != 0)
if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
return -EINVAL;
/* cx2388x has a 24-bit register space */
reg->val = cx_read(reg->reg&0xffffff);
Expand All @@ -1401,7 +1401,7 @@ static int vidioc_s_register (struct file *file, void *fh,
{
struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core;

if (reg->i2c_id != 0)
if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
return -EINVAL;
cx_write(reg->reg&0xffffff, reg->val);
return 0;
Expand Down
11 changes: 7 additions & 4 deletions drivers/media/video/pvrusb2/pvrusb2-hdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3256,8 +3256,8 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)


int pvr2_hdw_register_access(struct pvr2_hdw *hdw,
u32 chip_id, u64 reg_id,
int setFl,u32 *val_ptr)
u32 match_type, u32 match_chip, u64 reg_id,
int setFl,u64 *val_ptr)
{
#ifdef CONFIG_VIDEO_ADV_DEBUG
struct list_head *item;
Expand All @@ -3268,13 +3268,16 @@ int pvr2_hdw_register_access(struct pvr2_hdw *hdw,

if (!capable(CAP_SYS_ADMIN)) return -EPERM;

req.i2c_id = chip_id;
req.match_type = match_type;
req.match_chip = match_chip;
req.reg = reg_id;
if (setFl) req.val = *val_ptr;
mutex_lock(&hdw->i2c_list_lock); do {
list_for_each(item,&hdw->i2c_clients) {
cp = list_entry(item,struct pvr2_i2c_client,list);
if (cp->client->driver->id != chip_id) continue;
if (!v4l2_chip_match_i2c_client(cp->client, req.match_type, req.match_chip)) {
continue;
}
stat = pvr2_i2c_client_cmd(
cp,(setFl ? VIDIOC_DBG_S_REGISTER :
VIDIOC_DBG_G_REGISTER),&req);
Expand Down
7 changes: 4 additions & 3 deletions drivers/media/video/pvrusb2/pvrusb2-hdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,14 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,
enum pvr2_v4l_type index,int);

/* Direct read/write access to chip's registers:
chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx)
match_type - how to interpret match_chip (e.g. driver ID, i2c address)
match_chip - chip match value (e.g. I2C_DRIVERD_xxxx)
reg_id - register number to access
setFl - true to set the register, false to read it
val_ptr - storage location for source / result. */
int pvr2_hdw_register_access(struct pvr2_hdw *,
u32 chip_id,u64 reg_id,
int setFl,u32 *val_ptr);
u32 match_type, u32 match_chip,u64 reg_id,
int setFl,u64 *val_ptr);

/* The following entry points are all lower level things you normally don't
want to worry about. */
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/pvrusb2/pvrusb2-v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,11 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
case VIDIOC_DBG_S_REGISTER:
case VIDIOC_DBG_G_REGISTER:
{
u32 val;
u64 val;
struct v4l2_register *req = (struct v4l2_register *)arg;
if (cmd == VIDIOC_DBG_S_REGISTER) val = req->val;
ret = pvr2_hdw_register_access(
hdw,req->i2c_id,req->reg,
hdw,req->match_type,req->match_chip,req->reg,
cmd == VIDIOC_DBG_S_REGISTER,&val);
if (cmd == VIDIOC_DBG_G_REGISTER) req->val = val;
break;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/saa7115.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *ar
{
struct v4l2_register *reg = arg;

if (reg->i2c_id != I2C_DRIVERID_SAA711X)
if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/saa7127.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ static int saa7127_command(struct i2c_client *client,
{
struct v4l2_register *reg = arg;

if (reg->i2c_id != I2C_DRIVERID_SAA7127)
if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/tvp5150.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ static int tvp5150_command(struct i2c_client *c,
{
struct v4l2_register *reg = arg;

if (reg->i2c_id != I2C_DRIVERID_TVP5150)
if (!v4l2_chip_match_i2c_client(c, reg->match_type, reg->match_chip))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/upd64031a.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static int upd64031a_command(struct i2c_client *client, unsigned int cmd, void *
{
struct v4l2_register *reg = arg;

if (reg->i2c_id != I2C_DRIVERID_UPD64031A)
if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/upd64083.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static int upd64083_command(struct i2c_client *client, unsigned int cmd, void *a
{
struct v4l2_register *reg = arg;

if (reg->i2c_id != I2C_DRIVERID_UPD64083)
if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/usbvision/usbvision-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
struct v4l2_register *reg = arg;
int errCode;

if (reg->i2c_id != 0)
if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Expand All @@ -540,7 +540,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,

PDEBUG(DBG_IOCTL, "VIDIOC_DBG_%c_REGISTER reg=0x%02X, value=0x%02X",
cmd == VIDIOC_DBG_G_REGISTER ? 'G' : 'S',
(unsigned int)reg->reg, reg->val);
(unsigned int)reg->reg, (unsigned int)reg->val);
return 0;
}
#endif
Expand Down
43 changes: 37 additions & 6 deletions drivers/media/video/v4l2-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/i2c.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/pgtable.h>
Expand Down Expand Up @@ -365,13 +366,21 @@ static const char *v4l2_ioctls[] = {
[_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
[_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
[_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
#if 1
[_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
#endif
[_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
[_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
[_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
[_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS"
[_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
#if 1
[_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
[_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
[_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
[_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
[_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",

[_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
[_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
#endif
};
#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)

Expand All @@ -395,9 +404,6 @@ static const char *v4l2_int_ioctls[] = {
[_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
[_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG",

[_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
[_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",

[_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
[_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
[_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
Expand Down Expand Up @@ -947,6 +953,28 @@ u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id)
return **ctrl_classes;
}

int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_chip)
{
switch (match_type) {
case V4L2_CHIP_MATCH_I2C_DRIVER:
return (c != NULL && c->driver != NULL && c->driver->id == match_chip);
case V4L2_CHIP_MATCH_I2C_ADDR:
return (c != NULL && c->addr == match_chip);
default:
return 0;
}
}

int v4l2_chip_match_host(u32 match_type, u32 match_chip)
{
switch (match_type) {
case V4L2_CHIP_MATCH_HOST:
return match_chip == 0;
default:
return 0;
}
}

/* ----------------------------------------------------------------- */

EXPORT_SYMBOL(v4l2_norm_to_name);
Expand All @@ -970,6 +998,9 @@ EXPORT_SYMBOL(v4l2_ctrl_query_menu);
EXPORT_SYMBOL(v4l2_ctrl_query_fill);
EXPORT_SYMBOL(v4l2_ctrl_query_fill_std);

EXPORT_SYMBOL(v4l2_chip_match_i2c_client);
EXPORT_SYMBOL(v4l2_chip_match_host);

/*
* Local variables:
* c-basic-offset: 8
Expand Down
36 changes: 36 additions & 0 deletions drivers/media/video/videodev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,42 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
ret=vfd->vidioc_s_jpegcomp(file, fh, p);
break;
}
case VIDIOC_G_ENC_INDEX:
{
struct v4l2_enc_idx *p=arg;

if (!vfd->vidioc_g_enc_index)
break;
ret=vfd->vidioc_g_enc_index(file, fh, p);
if (!ret)
dbgarg (cmd, "entries=%d, entries_cap=%d\n",
p->entries,p->entries_cap);
break;
}
case VIDIOC_ENCODER_CMD:
{
struct v4l2_encoder_cmd *p=arg;

if (!vfd->vidioc_encoder_cmd)
break;
ret=vfd->vidioc_encoder_cmd(file, fh, p);
if (!ret)
dbgarg (cmd, "cmd=%d, flags=%d\n",
p->cmd,p->flags);
break;
}
case VIDIOC_TRY_ENCODER_CMD:
{
struct v4l2_encoder_cmd *p=arg;

if (!vfd->vidioc_try_encoder_cmd)
break;
ret=vfd->vidioc_try_encoder_cmd(file, fh, p);
if (!ret)
dbgarg (cmd, "cmd=%d, flags=%d\n",
p->cmd,p->flags);
break;
}
case VIDIOC_G_PARM:
{
struct v4l2_streamparm *p=arg;
Expand Down
Loading

0 comments on commit 100b425

Please sign in to comment.