Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] v4l2: standardize log start/end message

For drivers that properly use the v4l2 framework (i.e. set v4l2_dev in the
video_device struct), the start and end messages of VIDIOC_LOG_STATUS are
now generated automatically. People tended to forget these, but the v4l2-ctl
tool scans for these messages, and it also makes it easier to read the status
output in the kernel log.

The cx18, ivtv and bttv drivers were changed since they no longer need to
log these start/end messages.

In saa7164 two empty log_status functions were removed.

Also added a helper function to v4l2-ctrl.c that can be used as the
vidioc_log_status callback if all you need to do is to log the current control
values. This is now used by pwc and vivi.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Steven Toth <stoth@kernellabs.com>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
e2ecb257 eb224c29

+24 -43
-4
drivers/media/video/bt8xx/bttv-driver.c
··· 2035 2035 struct bttv_fh *fh = f; 2036 2036 struct bttv *btv = fh->btv; 2037 2037 2038 - pr_info("%d: ======== START STATUS CARD #%d ========\n", 2039 - btv->c.nr, btv->c.nr); 2040 2038 bttv_call_all(btv, core, log_status); 2041 - pr_info("%d: ======== END STATUS CARD #%d ========\n", 2042 - btv->c.nr, btv->c.nr); 2043 2039 return 0; 2044 2040 } 2045 2041
-4
drivers/media/video/cx18/cx18-ioctl.c
··· 1085 1085 struct v4l2_audio audin; 1086 1086 int i; 1087 1087 1088 - CX18_INFO("================= START STATUS CARD #%d " 1089 - "=================\n", cx->instance); 1090 1088 CX18_INFO("Version: %s Card: %s\n", CX18_VERSION, cx->card_name); 1091 1089 if (cx->hw_flags & CX18_HW_TVEEPROM) { 1092 1090 struct tveeprom tv; ··· 1118 1120 CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n", 1119 1121 (long long)cx->mpg_data_received, 1120 1122 (long long)cx->vbi_data_inserted); 1121 - CX18_INFO("================== END STATUS CARD #%d " 1122 - "==================\n", cx->instance); 1123 1123 return 0; 1124 1124 } 1125 1125
-5
drivers/media/video/ivtv/ivtv-ioctl.c
··· 1485 1485 struct v4l2_audio audin; 1486 1486 int i; 1487 1487 1488 - IVTV_INFO("================= START STATUS CARD #%d =================\n", 1489 - itv->instance); 1490 1488 IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION, itv->card_name); 1491 1489 if (itv->hw_flags & IVTV_HW_TVEEPROM) { 1492 1490 struct tveeprom tv; ··· 1566 1568 IVTV_INFO("Read MPG/VBI: %lld/%lld bytes\n", 1567 1569 (long long)itv->mpg_data_received, 1568 1570 (long long)itv->vbi_data_inserted); 1569 - IVTV_INFO("================== END STATUS CARD #%d ==================\n", 1570 - itv->instance); 1571 - 1572 1571 return 0; 1573 1572 } 1574 1573
+1 -9
drivers/media/video/pwc/pwc-v4l.c
··· 1146 1146 return ret; 1147 1147 } 1148 1148 1149 - static int pwc_log_status(struct file *file, void *priv) 1150 - { 1151 - struct pwc_device *pdev = video_drvdata(file); 1152 - 1153 - v4l2_ctrl_handler_log_status(&pdev->ctrl_handler, PWC_NAME); 1154 - return 0; 1155 - } 1156 - 1157 1149 const struct v4l2_ioctl_ops pwc_ioctl_ops = { 1158 1150 .vidioc_querycap = pwc_querycap, 1159 1151 .vidioc_enum_input = pwc_enum_input, ··· 1161 1169 .vidioc_dqbuf = pwc_dqbuf, 1162 1170 .vidioc_streamon = pwc_streamon, 1163 1171 .vidioc_streamoff = pwc_streamoff, 1164 - .vidioc_log_status = pwc_log_status, 1172 + .vidioc_log_status = v4l2_ctrl_log_status, 1165 1173 .vidioc_enum_framesizes = pwc_enum_framesizes, 1166 1174 .vidioc_enum_frameintervals = pwc_enum_frameintervals, 1167 1175 .vidioc_g_parm = pwc_g_parm,
-6
drivers/media/video/saa7164/saa7164-encoder.c
··· 791 791 return 0; 792 792 } 793 793 794 - static int vidioc_log_status(struct file *file, void *priv) 795 - { 796 - return 0; 797 - } 798 - 799 794 static int fill_queryctrl(struct saa7164_encoder_params *params, 800 795 struct v4l2_queryctrl *c) 801 796 { ··· 1342 1347 .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls, 1343 1348 .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, 1344 1349 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, 1345 - .vidioc_log_status = vidioc_log_status, 1346 1350 .vidioc_queryctrl = vidioc_queryctrl, 1347 1351 .vidioc_g_chip_ident = saa7164_g_chip_ident, 1348 1352 #ifdef CONFIG_VIDEO_ADV_DEBUG
-6
drivers/media/video/saa7164/saa7164-vbi.c
··· 730 730 return 0; 731 731 } 732 732 733 - static int vidioc_log_status(struct file *file, void *priv) 734 - { 735 - return 0; 736 - } 737 - 738 733 static int fill_queryctrl(struct saa7164_vbi_params *params, 739 734 struct v4l2_queryctrl *c) 740 735 { ··· 1251 1256 .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls, 1252 1257 .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, 1253 1258 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, 1254 - .vidioc_log_status = vidioc_log_status, 1255 1259 .vidioc_queryctrl = vidioc_queryctrl, 1256 1260 #if 0 1257 1261 .vidioc_g_chip_ident = saa7164_g_chip_ident,
+12
drivers/media/video/v4l2-ctrls.c
··· 2382 2382 v4l2_ctrl_unlock(ctrl); 2383 2383 } 2384 2384 EXPORT_SYMBOL(v4l2_ctrl_del_event); 2385 + 2386 + int v4l2_ctrl_log_status(struct file *file, void *fh) 2387 + { 2388 + struct video_device *vfd = video_devdata(file); 2389 + struct v4l2_fh *vfh = file->private_data; 2390 + 2391 + if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) && vfd->v4l2_dev) 2392 + v4l2_ctrl_handler_log_status(vfh->ctrl_handler, 2393 + vfd->v4l2_dev->name); 2394 + return 0; 2395 + } 2396 + EXPORT_SYMBOL(v4l2_ctrl_log_status);
+6
drivers/media/video/v4l2-ioctl.c
··· 1939 1939 { 1940 1940 if (!ops->vidioc_log_status) 1941 1941 break; 1942 + if (vfd->v4l2_dev) 1943 + pr_info("%s: ================= START STATUS =================\n", 1944 + vfd->v4l2_dev->name); 1942 1945 ret = ops->vidioc_log_status(file, fh); 1946 + if (vfd->v4l2_dev) 1947 + pr_info("%s: ================== END STATUS ==================\n", 1948 + vfd->v4l2_dev->name); 1943 1949 break; 1944 1950 } 1945 1951 #ifdef CONFIG_VIDEO_ADV_DEBUG
+1 -9
drivers/media/video/vivi.c
··· 959 959 return vb2_streamoff(&dev->vb_vidq, i); 960 960 } 961 961 962 - static int vidioc_log_status(struct file *file, void *priv) 963 - { 964 - struct vivi_dev *dev = video_drvdata(file); 965 - 966 - v4l2_ctrl_handler_log_status(&dev->ctrl_handler, dev->v4l2_dev.name); 967 - return 0; 968 - } 969 - 970 962 static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i) 971 963 { 972 964 return 0; ··· 1202 1210 .vidioc_s_input = vidioc_s_input, 1203 1211 .vidioc_streamon = vidioc_streamon, 1204 1212 .vidioc_streamoff = vidioc_streamoff, 1205 - .vidioc_log_status = vidioc_log_status, 1213 + .vidioc_log_status = v4l2_ctrl_log_status, 1206 1214 .vidioc_subscribe_event = vidioc_subscribe_event, 1207 1215 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1208 1216 };
+4
include/media/v4l2-ctrls.h
··· 492 492 void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl, 493 493 struct v4l2_subscribed_event *sev); 494 494 495 + /* Can be used as a vidioc_log_status function that just dumps all controls 496 + associated with the filehandle. */ 497 + int v4l2_ctrl_log_status(struct file *file, void *fh); 498 + 495 499 /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */ 496 500 int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); 497 501 int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);