Skip to content

Commit e2ecb25

Browse files
Hans VerkuilMauro Carvalho Chehab
authored andcommitted
[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>
1 parent eb224c2 commit e2ecb25

10 files changed

Lines changed: 24 additions & 43 deletions

File tree

‎drivers/media/video/bt8xx/bttv-driver.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,11 +2035,7 @@ static int bttv_log_status(struct file *file, void *f)
20352035
struct bttv_fh *fh = f;
20362036
struct bttv *btv = fh->btv;
20372037

2038-
pr_info("%d: ======== START STATUS CARD #%d ========\n",
2039-
btv->c.nr, btv->c.nr);
20402038
bttv_call_all(btv, core, log_status);
2041-
pr_info("%d: ======== END STATUS CARD #%d ========\n",
2042-
btv->c.nr, btv->c.nr);
20432039
return 0;
20442040
}
20452041

‎drivers/media/video/cx18/cx18-ioctl.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,6 @@ static int cx18_log_status(struct file *file, void *fh)
10851085
struct v4l2_audio audin;
10861086
int i;
10871087

1088-
CX18_INFO("================= START STATUS CARD #%d "
1089-
"=================\n", cx->instance);
10901088
CX18_INFO("Version: %s Card: %s\n", CX18_VERSION, cx->card_name);
10911089
if (cx->hw_flags & CX18_HW_TVEEPROM) {
10921090
struct tveeprom tv;
@@ -1120,8 +1118,6 @@ static int cx18_log_status(struct file *file, void *fh)
11201118
CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n",
11211119
(long long)cx->mpg_data_received,
11221120
(long long)cx->vbi_data_inserted);
1123-
CX18_INFO("================== END STATUS CARD #%d "
1124-
"==================\n", cx->instance);
11251121
return 0;
11261122
}
11271123

‎drivers/media/video/ivtv/ivtv-ioctl.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,8 +1485,6 @@ static int ivtv_log_status(struct file *file, void *fh)
14851485
struct v4l2_audio audin;
14861486
int i;
14871487

1488-
IVTV_INFO("================= START STATUS CARD #%d =================\n",
1489-
itv->instance);
14901488
IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION, itv->card_name);
14911489
if (itv->hw_flags & IVTV_HW_TVEEPROM) {
14921490
struct tveeprom tv;
@@ -1568,9 +1566,6 @@ static int ivtv_log_status(struct file *file, void *fh)
15681566
IVTV_INFO("Read MPG/VBI: %lld/%lld bytes\n",
15691567
(long long)itv->mpg_data_received,
15701568
(long long)itv->vbi_data_inserted);
1571-
IVTV_INFO("================== END STATUS CARD #%d ==================\n",
1572-
itv->instance);
1573-
15741569
return 0;
15751570
}
15761571

‎drivers/media/video/pwc/pwc-v4l.c‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,14 +1146,6 @@ static int pwc_s_parm(struct file *file, void *fh,
11461146
return ret;
11471147
}
11481148

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-
11571149
const struct v4l2_ioctl_ops pwc_ioctl_ops = {
11581150
.vidioc_querycap = pwc_querycap,
11591151
.vidioc_enum_input = pwc_enum_input,
@@ -1169,7 +1161,7 @@ const struct v4l2_ioctl_ops pwc_ioctl_ops = {
11691161
.vidioc_dqbuf = pwc_dqbuf,
11701162
.vidioc_streamon = pwc_streamon,
11711163
.vidioc_streamoff = pwc_streamoff,
1172-
.vidioc_log_status = pwc_log_status,
1164+
.vidioc_log_status = v4l2_ctrl_log_status,
11731165
.vidioc_enum_framesizes = pwc_enum_framesizes,
11741166
.vidioc_enum_frameintervals = pwc_enum_frameintervals,
11751167
.vidioc_g_parm = pwc_g_parm,

‎drivers/media/video/saa7164/saa7164-encoder.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -791,11 +791,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
791791
return 0;
792792
}
793793

794-
static int vidioc_log_status(struct file *file, void *priv)
795-
{
796-
return 0;
797-
}
798-
799794
static int fill_queryctrl(struct saa7164_encoder_params *params,
800795
struct v4l2_queryctrl *c)
801796
{
@@ -1347,7 +1342,6 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
13471342
.vidioc_g_ext_ctrls = vidioc_g_ext_ctrls,
13481343
.vidioc_s_ext_ctrls = vidioc_s_ext_ctrls,
13491344
.vidioc_try_ext_ctrls = vidioc_try_ext_ctrls,
1350-
.vidioc_log_status = vidioc_log_status,
13511345
.vidioc_queryctrl = vidioc_queryctrl,
13521346
.vidioc_g_chip_ident = saa7164_g_chip_ident,
13531347
#ifdef CONFIG_VIDEO_ADV_DEBUG

‎drivers/media/video/saa7164/saa7164-vbi.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
730730
return 0;
731731
}
732732

733-
static int vidioc_log_status(struct file *file, void *priv)
734-
{
735-
return 0;
736-
}
737-
738733
static int fill_queryctrl(struct saa7164_vbi_params *params,
739734
struct v4l2_queryctrl *c)
740735
{
@@ -1256,7 +1251,6 @@ static const struct v4l2_ioctl_ops vbi_ioctl_ops = {
12561251
.vidioc_g_ext_ctrls = vidioc_g_ext_ctrls,
12571252
.vidioc_s_ext_ctrls = vidioc_s_ext_ctrls,
12581253
.vidioc_try_ext_ctrls = vidioc_try_ext_ctrls,
1259-
.vidioc_log_status = vidioc_log_status,
12601254
.vidioc_queryctrl = vidioc_queryctrl,
12611255
#if 0
12621256
.vidioc_g_chip_ident = saa7164_g_chip_ident,

‎drivers/media/video/v4l2-ctrls.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,3 +2382,15 @@ void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl,
23822382
v4l2_ctrl_unlock(ctrl);
23832383
}
23842384
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);

‎drivers/media/video/v4l2-ioctl.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,13 @@ static long __video_do_ioctl(struct file *file,
19391939
{
19401940
if (!ops->vidioc_log_status)
19411941
break;
1942+
if (vfd->v4l2_dev)
1943+
pr_info("%s: ================= START STATUS =================\n",
1944+
vfd->v4l2_dev->name);
19421945
ret = ops->vidioc_log_status(file, fh);
1946+
if (vfd->v4l2_dev)
1947+
pr_info("%s: ================== END STATUS ==================\n",
1948+
vfd->v4l2_dev->name);
19431949
break;
19441950
}
19451951
#ifdef CONFIG_VIDEO_ADV_DEBUG

‎drivers/media/video/vivi.c‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -959,14 +959,6 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
959959
return vb2_streamoff(&dev->vb_vidq, i);
960960
}
961961

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-
970962
static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i)
971963
{
972964
return 0;
@@ -1210,7 +1202,7 @@ static const struct v4l2_ioctl_ops vivi_ioctl_ops = {
12101202
.vidioc_s_input = vidioc_s_input,
12111203
.vidioc_streamon = vidioc_streamon,
12121204
.vidioc_streamoff = vidioc_streamoff,
1213-
.vidioc_log_status = vidioc_log_status,
1205+
.vidioc_log_status = v4l2_ctrl_log_status,
12141206
.vidioc_subscribe_event = vidioc_subscribe_event,
12151207
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
12161208
};

‎include/media/v4l2-ctrls.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,10 @@ void v4l2_ctrl_add_event(struct v4l2_ctrl *ctrl,
492492
void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl,
493493
struct v4l2_subscribed_event *sev);
494494

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+
495499
/* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */
496500
int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
497501
int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);

0 commit comments

Comments
 (0)