Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb

* 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.

+184 -38
+2 -2
drivers/media/dvb/dvb-usb/cxusb.c
··· 469 469 fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) { 470 470 471 471 fw->data[BLUEBIRD_01_ID_OFFSET + 2] = 472 - udev->descriptor.idProduct + 1; 472 + le16_to_cpu(udev->descriptor.idProduct) + 1; 473 473 fw->data[BLUEBIRD_01_ID_OFFSET + 3] = 474 - udev->descriptor.idProduct >> 8; 474 + le16_to_cpu(udev->descriptor.idProduct) >> 8; 475 475 476 476 return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2); 477 477 }
+2
drivers/media/dvb/dvb-usb/digitv.c
··· 119 119 struct dvb_usb_adapter *adap = fe->dvb->priv; 120 120 u8 b[5]; 121 121 dvb_usb_tuner_calc_regs(fe,fep,b, 5); 122 + if (fe->ops.i2c_gate_ctrl) 123 + fe->ops.i2c_gate_ctrl(fe, 1); 122 124 return digitv_ctrl_msg(adap->dev, USB_WRITE_TUNER, 0, &b[1], 4, NULL, 0); 123 125 } 124 126
+1 -3
drivers/media/video/cafe_ccic.c
··· 1022 1022 char __user *buffer, size_t len, loff_t *pos) 1023 1023 { 1024 1024 struct cafe_camera *cam = filp->private_data; 1025 - int ret; 1025 + int ret = 0; 1026 1026 1027 1027 /* 1028 1028 * Perhaps we're in speculative read mode and already ··· 1251 1251 1252 1252 if (cam->n_sbufs == 0) /* no luck at all - ret already set */ 1253 1253 kfree(cam->sb_bufs); 1254 - else 1255 - ret = 0; 1256 1254 req->count = cam->n_sbufs; /* In case of partial success */ 1257 1255 1258 1256 out:
+3 -3
drivers/media/video/cx25840/cx25840-core.c
··· 633 633 { 634 634 struct v4l2_register *reg = arg; 635 635 636 - if (reg->i2c_id != I2C_DRIVERID_CX25840) 636 + if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) 637 637 return -EINVAL; 638 638 if (!capable(CAP_SYS_ADMIN)) 639 639 return -EPERM; ··· 903 903 state->vbi_line_offset = 8; 904 904 state->id = id; 905 905 906 + i2c_attach_client(client); 907 + 906 908 if (state->is_cx25836) 907 909 cx25836_initialize(client); 908 910 else 909 911 cx25840_initialize(client, 1); 910 - 911 - i2c_attach_client(client); 912 912 913 913 return 0; 914 914 }
+1 -1
drivers/media/video/cx25840/cx25840-firmware.c
··· 37 37 */ 38 38 #define FWSEND 48 39 39 40 - #define FWDEV(x) &((x)->adapter->dev) 40 + #define FWDEV(x) &((x)->dev) 41 41 42 42 static char *firmware = FWFILE; 43 43
+2 -2
drivers/media/video/cx88/cx88-video.c
··· 1389 1389 { 1390 1390 struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; 1391 1391 1392 - if (reg->i2c_id != 0) 1392 + if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 1393 1393 return -EINVAL; 1394 1394 /* cx2388x has a 24-bit register space */ 1395 1395 reg->val = cx_read(reg->reg&0xffffff); ··· 1401 1401 { 1402 1402 struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; 1403 1403 1404 - if (reg->i2c_id != 0) 1404 + if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 1405 1405 return -EINVAL; 1406 1406 cx_write(reg->reg&0xffffff, reg->val); 1407 1407 return 0;
+7 -4
drivers/media/video/pvrusb2/pvrusb2-hdw.c
··· 3256 3256 3257 3257 3258 3258 int pvr2_hdw_register_access(struct pvr2_hdw *hdw, 3259 - u32 chip_id, u64 reg_id, 3260 - int setFl,u32 *val_ptr) 3259 + u32 match_type, u32 match_chip, u64 reg_id, 3260 + int setFl,u64 *val_ptr) 3261 3261 { 3262 3262 #ifdef CONFIG_VIDEO_ADV_DEBUG 3263 3263 struct list_head *item; ··· 3268 3268 3269 3269 if (!capable(CAP_SYS_ADMIN)) return -EPERM; 3270 3270 3271 - req.i2c_id = chip_id; 3271 + req.match_type = match_type; 3272 + req.match_chip = match_chip; 3272 3273 req.reg = reg_id; 3273 3274 if (setFl) req.val = *val_ptr; 3274 3275 mutex_lock(&hdw->i2c_list_lock); do { 3275 3276 list_for_each(item,&hdw->i2c_clients) { 3276 3277 cp = list_entry(item,struct pvr2_i2c_client,list); 3277 - if (cp->client->driver->id != chip_id) continue; 3278 + if (!v4l2_chip_match_i2c_client(cp->client, req.match_type, req.match_chip)) { 3279 + continue; 3280 + } 3278 3281 stat = pvr2_i2c_client_cmd( 3279 3282 cp,(setFl ? VIDIOC_DBG_S_REGISTER : 3280 3283 VIDIOC_DBG_G_REGISTER),&req);
+4 -3
drivers/media/video/pvrusb2/pvrusb2-hdw.h
··· 217 217 enum pvr2_v4l_type index,int); 218 218 219 219 /* Direct read/write access to chip's registers: 220 - chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx) 220 + match_type - how to interpret match_chip (e.g. driver ID, i2c address) 221 + match_chip - chip match value (e.g. I2C_DRIVERD_xxxx) 221 222 reg_id - register number to access 222 223 setFl - true to set the register, false to read it 223 224 val_ptr - storage location for source / result. */ 224 225 int pvr2_hdw_register_access(struct pvr2_hdw *, 225 - u32 chip_id,u64 reg_id, 226 - int setFl,u32 *val_ptr); 226 + u32 match_type, u32 match_chip,u64 reg_id, 227 + int setFl,u64 *val_ptr); 227 228 228 229 /* The following entry points are all lower level things you normally don't 229 230 want to worry about. */
+2 -2
drivers/media/video/pvrusb2/pvrusb2-v4l2.c
··· 740 740 case VIDIOC_DBG_S_REGISTER: 741 741 case VIDIOC_DBG_G_REGISTER: 742 742 { 743 - u32 val; 743 + u64 val; 744 744 struct v4l2_register *req = (struct v4l2_register *)arg; 745 745 if (cmd == VIDIOC_DBG_S_REGISTER) val = req->val; 746 746 ret = pvr2_hdw_register_access( 747 - hdw,req->i2c_id,req->reg, 747 + hdw,req->match_type,req->match_chip,req->reg, 748 748 cmd == VIDIOC_DBG_S_REGISTER,&val); 749 749 if (cmd == VIDIOC_DBG_G_REGISTER) req->val = val; 750 750 break;
+1 -1
drivers/media/video/saa7115.c
··· 1425 1425 { 1426 1426 struct v4l2_register *reg = arg; 1427 1427 1428 - if (reg->i2c_id != I2C_DRIVERID_SAA711X) 1428 + if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) 1429 1429 return -EINVAL; 1430 1430 if (!capable(CAP_SYS_ADMIN)) 1431 1431 return -EPERM;
+1 -1
drivers/media/video/saa7127.c
··· 619 619 { 620 620 struct v4l2_register *reg = arg; 621 621 622 - if (reg->i2c_id != I2C_DRIVERID_SAA7127) 622 + if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) 623 623 return -EINVAL; 624 624 if (!capable(CAP_SYS_ADMIN)) 625 625 return -EPERM;
+1 -1
drivers/media/video/tvp5150.c
··· 955 955 { 956 956 struct v4l2_register *reg = arg; 957 957 958 - if (reg->i2c_id != I2C_DRIVERID_TVP5150) 958 + if (!v4l2_chip_match_i2c_client(c, reg->match_type, reg->match_chip)) 959 959 return -EINVAL; 960 960 if (!capable(CAP_SYS_ADMIN)) 961 961 return -EPERM;
+1 -1
drivers/media/video/upd64031a.c
··· 167 167 { 168 168 struct v4l2_register *reg = arg; 169 169 170 - if (reg->i2c_id != I2C_DRIVERID_UPD64031A) 170 + if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) 171 171 return -EINVAL; 172 172 if (!capable(CAP_SYS_ADMIN)) 173 173 return -EPERM;
+1 -1
drivers/media/video/upd64083.c
··· 144 144 { 145 145 struct v4l2_register *reg = arg; 146 146 147 - if (reg->i2c_id != I2C_DRIVERID_UPD64083) 147 + if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) 148 148 return -EINVAL; 149 149 if (!capable(CAP_SYS_ADMIN)) 150 150 return -EPERM;
+2 -2
drivers/media/video/usbvision/usbvision-video.c
··· 521 521 struct v4l2_register *reg = arg; 522 522 int errCode; 523 523 524 - if (reg->i2c_id != 0) 524 + if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 525 525 return -EINVAL; 526 526 if (!capable(CAP_SYS_ADMIN)) 527 527 return -EPERM; ··· 540 540 541 541 PDEBUG(DBG_IOCTL, "VIDIOC_DBG_%c_REGISTER reg=0x%02X, value=0x%02X", 542 542 cmd == VIDIOC_DBG_G_REGISTER ? 'G' : 'S', 543 - (unsigned int)reg->reg, reg->val); 543 + (unsigned int)reg->reg, (unsigned int)reg->val); 544 544 return 0; 545 545 } 546 546 #endif
+37 -6
drivers/media/video/v4l2-common.c
··· 51 51 #include <linux/mm.h> 52 52 #include <linux/string.h> 53 53 #include <linux/errno.h> 54 + #include <linux/i2c.h> 54 55 #include <asm/uaccess.h> 55 56 #include <asm/system.h> 56 57 #include <asm/pgtable.h> ··· 366 365 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT", 367 366 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY", 368 367 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY", 369 - #if 1 370 368 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP", 371 - #endif 372 369 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS", 373 370 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS", 374 371 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS", 375 - [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS" 372 + [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS", 373 + #if 1 374 + [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES", 375 + [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS", 376 + [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX", 377 + [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD", 378 + [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD", 379 + 380 + [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", 381 + [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", 382 + #endif 376 383 }; 377 384 #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) 378 385 ··· 403 394 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR", 404 395 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", 405 396 [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG", 406 - 407 - [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", 408 - [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", 409 397 410 398 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE", 411 399 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET", ··· 953 947 return **ctrl_classes; 954 948 } 955 949 950 + int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_chip) 951 + { 952 + switch (match_type) { 953 + case V4L2_CHIP_MATCH_I2C_DRIVER: 954 + return (c != NULL && c->driver != NULL && c->driver->id == match_chip); 955 + case V4L2_CHIP_MATCH_I2C_ADDR: 956 + return (c != NULL && c->addr == match_chip); 957 + default: 958 + return 0; 959 + } 960 + } 961 + 962 + int v4l2_chip_match_host(u32 match_type, u32 match_chip) 963 + { 964 + switch (match_type) { 965 + case V4L2_CHIP_MATCH_HOST: 966 + return match_chip == 0; 967 + default: 968 + return 0; 969 + } 970 + } 971 + 956 972 /* ----------------------------------------------------------------- */ 957 973 958 974 EXPORT_SYMBOL(v4l2_norm_to_name); ··· 997 969 EXPORT_SYMBOL(v4l2_ctrl_query_menu); 998 970 EXPORT_SYMBOL(v4l2_ctrl_query_fill); 999 971 EXPORT_SYMBOL(v4l2_ctrl_query_fill_std); 972 + 973 + EXPORT_SYMBOL(v4l2_chip_match_i2c_client); 974 + EXPORT_SYMBOL(v4l2_chip_match_host); 1000 975 1001 976 /* 1002 977 * Local variables:
+36
drivers/media/video/videodev.c
··· 1342 1342 ret=vfd->vidioc_s_jpegcomp(file, fh, p); 1343 1343 break; 1344 1344 } 1345 + case VIDIOC_G_ENC_INDEX: 1346 + { 1347 + struct v4l2_enc_idx *p=arg; 1348 + 1349 + if (!vfd->vidioc_g_enc_index) 1350 + break; 1351 + ret=vfd->vidioc_g_enc_index(file, fh, p); 1352 + if (!ret) 1353 + dbgarg (cmd, "entries=%d, entries_cap=%d\n", 1354 + p->entries,p->entries_cap); 1355 + break; 1356 + } 1357 + case VIDIOC_ENCODER_CMD: 1358 + { 1359 + struct v4l2_encoder_cmd *p=arg; 1360 + 1361 + if (!vfd->vidioc_encoder_cmd) 1362 + break; 1363 + ret=vfd->vidioc_encoder_cmd(file, fh, p); 1364 + if (!ret) 1365 + dbgarg (cmd, "cmd=%d, flags=%d\n", 1366 + p->cmd,p->flags); 1367 + break; 1368 + } 1369 + case VIDIOC_TRY_ENCODER_CMD: 1370 + { 1371 + struct v4l2_encoder_cmd *p=arg; 1372 + 1373 + if (!vfd->vidioc_try_encoder_cmd) 1374 + break; 1375 + ret=vfd->vidioc_try_encoder_cmd(file, fh, p); 1376 + if (!ret) 1377 + dbgarg (cmd, "cmd=%d, flags=%d\n", 1378 + p->cmd,p->flags); 1379 + break; 1380 + } 1345 1381 case VIDIOC_G_PARM: 1346 1382 { 1347 1383 struct v4l2_streamparm *p=arg;
+66 -5
include/linux/videodev2.h
··· 1193 1193 }; 1194 1194 1195 1195 /* 1196 + * M P E G S E R V I C E S 1197 + * 1198 + * NOTE: EXPERIMENTAL API 1199 + */ 1200 + #if 1 1201 + #define V4L2_ENC_IDX_FRAME_I (0) 1202 + #define V4L2_ENC_IDX_FRAME_P (1) 1203 + #define V4L2_ENC_IDX_FRAME_B (2) 1204 + #define V4L2_ENC_IDX_FRAME_MASK (0xf) 1205 + 1206 + struct v4l2_enc_idx_entry { 1207 + __u64 offset; 1208 + __u64 pts; 1209 + __u32 length; 1210 + __u32 flags; 1211 + __u32 reserved[2]; 1212 + }; 1213 + 1214 + #define V4L2_ENC_IDX_ENTRIES (64) 1215 + struct v4l2_enc_idx { 1216 + __u32 entries; 1217 + __u32 entries_cap; 1218 + __u32 reserved[4]; 1219 + struct v4l2_enc_idx_entry entry[V4L2_ENC_IDX_ENTRIES]; 1220 + }; 1221 + 1222 + 1223 + #define V4L2_ENC_CMD_START (0) 1224 + #define V4L2_ENC_CMD_STOP (1) 1225 + #define V4L2_ENC_CMD_PAUSE (2) 1226 + #define V4L2_ENC_CMD_RESUME (3) 1227 + 1228 + /* Flags for V4L2_ENC_CMD_STOP */ 1229 + #define V4L2_ENC_CMD_STOP_AT_GOP_END (1 << 0) 1230 + 1231 + struct v4l2_encoder_cmd { 1232 + __u32 cmd; 1233 + __u32 flags; 1234 + union { 1235 + struct { 1236 + __u32 data[8]; 1237 + } raw; 1238 + }; 1239 + }; 1240 + 1241 + #endif 1242 + 1243 + 1244 + /* 1196 1245 * D A T A S E R V I C E S ( V B I ) 1197 1246 * 1198 1247 * Data services API by Michael Schimek ··· 1352 1303 1353 1304 /* 1354 1305 * A D V A N C E D D E B U G G I N G 1306 + * 1307 + * NOTE: EXPERIMENTAL API 1355 1308 */ 1356 1309 1357 1310 /* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */ 1311 + 1312 + #define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */ 1313 + #define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver ID */ 1314 + #define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ 1315 + 1358 1316 struct v4l2_register { 1317 + __u32 match_type; /* Match type */ 1318 + __u32 match_chip; /* Match this chip, meaning determined by match_type */ 1359 1319 __u64 reg; 1360 - __u32 i2c_id; /* I2C driver ID of the I2C chip, or 0 for the host */ 1361 - __u32 val; 1320 + __u64 val; 1362 1321 }; 1363 1322 1364 1323 /* ··· 1435 1378 #if 1 1436 1379 #define VIDIOC_ENUM_FRAMESIZES _IOWR ('V', 74, struct v4l2_frmsizeenum) 1437 1380 #define VIDIOC_ENUM_FRAMEINTERVALS _IOWR ('V', 75, struct v4l2_frmivalenum) 1381 + #define VIDIOC_G_ENC_INDEX _IOR ('V', 76, struct v4l2_enc_idx) 1382 + #define VIDIOC_ENCODER_CMD _IOWR ('V', 77, struct v4l2_encoder_cmd) 1383 + #define VIDIOC_TRY_ENCODER_CMD _IOWR ('V', 78, struct v4l2_encoder_cmd) 1384 + 1385 + /* Experimental, only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */ 1386 + #define VIDIOC_DBG_S_REGISTER _IOW ('V', 79, struct v4l2_register) 1387 + #define VIDIOC_DBG_G_REGISTER _IOWR ('V', 80, struct v4l2_register) 1438 1388 #endif 1439 - /* only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */ 1440 - #define VIDIOC_DBG_S_REGISTER _IOW ('d', 100, struct v4l2_register) 1441 - #define VIDIOC_DBG_G_REGISTER _IOWR('d', 101, struct v4l2_register) 1442 1389 1443 1390 #ifdef __OLD_VIDIOC_ 1444 1391 /* for compatibility, will go away some day */
+8
include/media/v4l2-common.h
··· 94 94 95 95 /* ------------------------------------------------------------------------- */ 96 96 97 + /* Register/chip ident helper function */ 98 + 99 + struct i2c_client; /* forward reference */ 100 + int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 id_type, u32 chip_id); 101 + int v4l2_chip_match_host(u32 id_type, u32 chip_id); 102 + 103 + /* ------------------------------------------------------------------------- */ 104 + 97 105 /* Internal ioctls */ 98 106 99 107 /* VIDIOC_INT_DECODE_VBI_LINE */
+6
include/media/v4l2-dev.h
··· 271 271 struct v4l2_jpegcompression *a); 272 272 int (*vidioc_s_jpegcomp) (struct file *file, void *fh, 273 273 struct v4l2_jpegcompression *a); 274 + int (*vidioc_g_enc_index) (struct file *file, void *fh, 275 + struct v4l2_enc_idx *a); 276 + int (*vidioc_encoder_cmd) (struct file *file, void *fh, 277 + struct v4l2_encoder_cmd *a); 278 + int (*vidioc_try_encoder_cmd) (struct file *file, void *fh, 279 + struct v4l2_encoder_cmd *a); 274 280 275 281 /* Stream type-dependent parameter ioctls */ 276 282 int (*vidioc_g_parm) (struct file *file, void *fh,