output human readable form of the .status field from VIDIOC_ENUMINPUT
PATCH 1/1 output human readable form of the .status field from VIDIOC_ENUMINPUT
The attach patch modifies v4l2-ctl -I to also output signal status as detected by the driver/hardware. This info is available in the status field of the data returned by VIDIOC_ENUMINPUT which v4l2-ctl -I already calls. The strings are copied from the v4l2 api specification and could perhaps be modified a bit to fit the application.
Best regards
Sigmund Augdal
# HG changeset patch
# User root@localhost
# Date 1256130852 -10800
# Node ID b335284d31a3fa85f1bb2a94956045bcb2e7c2c2
# Parent 7e273bee86017aa1568bb92e6f717eb585561578
changed --get-input to parse and output the status field of VIDIOC_ENUMINPUT
v4l2-apps/util/v4l2-ctl.cpp +39 -1
@@ -572,6 +572,44 @@ static std::string flags2s(unsigned val, return s; } +static std::string status2s(__u32 status) +{ + switch (status) { + case 0: + return "Signal OK"; + case V4L2_IN_ST_NO_POWER: + return "Attached device is off."; + case V4L2_IN_ST_NO_SIGNAL: + return "No signal"; + case V4L2_IN_ST_NO_COLOR: + return "The hardware supports color decoding, but does not detect color modulation in the signal."; + case V4L2_IN_ST_HFLIP: + return "The input is connected to a device that produces a signal that is flipped horizontally and does not correct this before passing the signal to userspace."; + case V4L2_IN_ST_VFLIP: + return "The input is connected to a device that produces a signal that is flipped vertically and does not correct this before passing the signal to userspace. Note that a 180 degree rotation is the same as HFLIP | VFLIP"; + case V4L2_IN_ST_NO_H_LOCK: + return "No horizontal sync lock."; + case V4L2_IN_ST_COLOR_KILL: + return "A color killer circuit automatically disables color decoding when it detects no color modulation. When this flag is set the color killer is enabled and has shut off color decoding."; + case V4L2_IN_ST_NO_SYNC: + return "No synchronization lock."; + case V4L2_IN_ST_NO_EQU: + return "No equalizer lock."; + case V4L2_IN_ST_NO_CARRIER: + return "Carrier recovery failed."; + case V4L2_IN_ST_MACROVISION: + return "Macrovision is an analog copy prevention system mangling the video signal to confuse video recorders. When this flag is set Macrovision has been detected."; + case V4L2_IN_ST_NO_ACCESS: + return "Conditional access denied."; + case V4L2_IN_ST_VTR: + return "VTR time constant. [?]"; + default: + char msg[20]; + sprintf(msg, "unknown(%d)", status); + return msg; + } +} + static void print_sliced_vbi_cap(struct v4l2_sliced_vbi_cap &cap) { printf("\tType : %s\n", buftype2s(cap.type).c_str());
@@ -2707,7 +2745,7 @@ set_vid_fmt_error: printf("Video input : %d", input); vin.index = input; if (ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0) - printf(" (%s)", vin.name); + printf(" (%s: %s)", vin.name, status2s(vin.status).c_str()); printf("\n"); } }
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 output human readable form of the .status field from VIDIOC_ENUMINPUT
The attach patch modifies v4l2-ctl -I to also output signal status as detected by the driver/hardware. This info is available in the status field of the data returned by VIDIOC_ENUMINPUT which v4l2-ctl -I already calls. The strings are copied from the v4l2 api specification and could perhaps be modified a bit to fit the application.
Best regards
Sigmund Augdal
# HG changeset patch
# User root@localhost
# Date 1256130852 -10800
# Node ID b335284d31a3fa85f1bb2a94956045bcb2e7c2c2
# Parent 7e273bee86017aa1568bb92e6f717eb585561578
changed --get-input to parse and output the status field of VIDIOC_ENUMINPUT
v4l2-apps/util/v4l2-ctl.cpp +39 -1
@@ -572,6 +572,44 @@ static std::string flags2s(unsigned val, return s; } +static std::string status2s(__u32 status) +{ + switch (status) { + case 0: + return "Signal OK"; + case V4L2_IN_ST_NO_POWER: + return "Attached device is off."; + case V4L2_IN_ST_NO_SIGNAL: + return "No signal"; + case V4L2_IN_ST_NO_COLOR: + return "The hardware supports color decoding, but does not detect color modulation in the signal."; + case V4L2_IN_ST_HFLIP: + return "The input is connected to a device that produces a signal that is flipped horizontally and does not correct this before passing the signal to userspace."; + case V4L2_IN_ST_VFLIP: + return "The input is connected to a device that produces a signal that is flipped vertically and does not correct this before passing the signal to userspace. Note that a 180 degree rotation is the same as HFLIP | VFLIP"; + case V4L2_IN_ST_NO_H_LOCK: + return "No horizontal sync lock."; + case V4L2_IN_ST_COLOR_KILL: + return "A color killer circuit automatically disables color decoding when it detects no color modulation. When this flag is set the color killer is enabled and has shut off color decoding."; + case V4L2_IN_ST_NO_SYNC: + return "No synchronization lock."; + case V4L2_IN_ST_NO_EQU: + return "No equalizer lock."; + case V4L2_IN_ST_NO_CARRIER: + return "Carrier recovery failed."; + case V4L2_IN_ST_MACROVISION: + return "Macrovision is an analog copy prevention system mangling the video signal to confuse video recorders. When this flag is set Macrovision has been detected."; + case V4L2_IN_ST_NO_ACCESS: + return "Conditional access denied."; + case V4L2_IN_ST_VTR: + return "VTR time constant. [?]"; + default: + char msg[20]; + sprintf(msg, "unknown(%d)", status); + return msg; + } +} + static void print_sliced_vbi_cap(struct v4l2_sliced_vbi_cap &cap) { printf("\tType : %s\n", buftype2s(cap.type).c_str());
@@ -2707,7 +2745,7 @@ set_vid_fmt_error: printf("Video input : %d", input); vin.index = input; if (ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0) - printf(" (%s)", vin.name); + printf(" (%s: %s)", vin.name, status2s(vin.status).c_str()); printf("\n"); } }
Quoted 11 lines
The attach patch modifies v4l2-ctl -I to also output signal status as detected by the driver/hardware. This info is available in the status field of the data returned by
VIDIOC_ENUMINPUTwhich v4l2-ctl -I already calls. The strings are copied from the v4l2 api specification and could perhaps be modified a bit to fit the application.Best regards
Sigmund Augdal
Hi Sigmund,
This doesn't work right: the status field is a bitmask, so multiple bits can be set at the same time. So a switch is not the right choice for that. Look at some of the other functions to print bitmasks in v4l2-ctl.cpp for ideas on how to implement this properly.
But it will be nice to have this in v4l2-ctl!
Regards,
Hans
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
Quoted 12 lines · Hans Verkuil
Quoted 11 lines
The attach patch modifies v4l2-ctl -I to also output signal status as detected by the driver/hardware. This info is available in the status field of the data returned by
VIDIOC_ENUMINPUTwhich v4l2-ctl -I already calls. The strings are copied from the v4l2 api specification and could perhaps be modified a bit to fit the application.Best regards
Sigmund Augdal
Quoted 8 lines
Hi Sigmund,
This doesn't work right: the status field is a bitmask, so multiple bits can be set at the same time. So a switch is not the right choice for that. Look at some of the other functions to print bitmasks in v4l2-ctl.cpp for ideas on how to implement this properly.
But it will be nice to have this in v4l2-ctl!
Right, I realized this shortly after sending. I'll take a look at this today. However, I'm unsure how to handle the value 0. It seems this is used both for "signal detected and everything is ok" and "driver has no clue if there is a signal or not". Any feedback welcome.
Best regards
Sigmund Augdal
Quoted 9 lines
Regards,
Hans
--
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
Quoted 20 lines · Sigmund Augdal
Quoted 19 lines · Hans Verkuil
Quoted 11 lines
The attach patch modifies v4l2-ctl -I to also output signal status as detected by the driver/hardware. This info is available in the status field of the data returned by
VIDIOC_ENUMINPUTwhich v4l2-ctl -I already calls. The strings are copied from the v4l2 api specification and could perhaps be modified a bit to fit the application.Best regards
Sigmund Augdal
Hi Sigmund,
This doesn't work right: the status field is a bitmask, so multiple bits can be set at the same time. So a switch is not the right choice for that. Look at some of the other functions to print bitmasks in v4l2-ctl.cpp for ideas on how to implement this properly.
Quoted 5 lines
Quoted 1 line
But it will be nice to have this in v4l2-ctl!
Right, I realized this shortly after sending. I'll take a look at this today. However, I'm unsure how to handle the value 0. It seems this is used both for "signal detected and everything is ok" and "driver has no clue if there is a signal or not". Any feedback welcome.
Attached is my second attempt at this. It should be slightly cleaner. I also changed the output format a bit so the line containing input name is unchanged compared to current v4l2-ctl (in case anyone has scripts that depend on it). Now signal status is outputted on a new line.
Best regards
Sigmund Augdal
Quoted 14 lines
Best regards
Sigmund Augdal
Quoted 9 lines
Regards,
Hans
--
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
Quoted 20 lines · Sigmund Augdal
Quoted 19 lines · Hans Verkuil
Quoted 11 lines
The attach patch modifies v4l2-ctl -I to also output signal status as detected by the driver/hardware. This info is available in the status field of the data returned by
VIDIOC_ENUMINPUTwhich v4l2-ctl -I already calls. The strings are copied from the v4l2 api specification and could perhaps be modified a bit to fit the application.Best regards
Sigmund Augdal
Hi Sigmund,
This doesn't work right: the status field is a bitmask, so multiple bits can be set at the same time. So a switch is not the right choice for that. Look at some of the other functions to print bitmasks in v4l2-ctl.cpp for ideas on how to implement this properly.
Quoted 5 lines
Quoted 1 line
But it will be nice to have this in v4l2-ctl!
Right, I realized this shortly after sending. I'll take a look at this today. However, I'm unsure how to handle the value 0. It seems this is used both for "signal detected and everything is ok" and "driver has no clue if there is a signal or not". Any feedback welcome.
And again, this time with the attachment.
Best regards
Sigmund Augdal
Quoted 14 lines
Best regards
Sigmund Augdal
Quoted 9 lines
Regards,
Hans
--
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
# HG changeset patch
# User root@localhost
# Date 1256130852 -10800
# Node ID 394c4b75e54634483c5002bf804129db84cc8be3
# Parent f6680fa8e7ec88bbfbedddc7c3e99003e328a1aa
changed --get-input to parse and output the status field of VIDIOC_ENUMINPUT
v4l2-apps/util/v4l2-ctl.cpp +23 -0
@@ -568,6 +568,24 @@ static std::string flags2s(unsigned val, return s; } +static const flag_def status_def[] = { + {V4L2_IN_ST_NO_POWER,"Attached device is off."}, + {V4L2_IN_ST_NO_SIGNAL, "No signal"}, + {V4L2_IN_ST_NO_COLOR, "The hardware supports color decoding, but does not detect color modulation in the signal."}, + {V4L2_IN_ST_HFLIP, "The input is connected to a device that produces a signal that is flipped horizontally and does not correct this before passing the signal to userspace."}, + {V4L2_IN_ST_VFLIP, "The input is connected to a device that produces a signal that is flipped vertically and does not correct this before passing the signal to userspace. Note that a 180 degree rotation is the same as HFLIP | VFLIP"}, + {V4L2_IN_ST_NO_H_LOCK, "No horizontal sync lock."}, + {V4L2_IN_ST_COLOR_KILL, "A color killer circuit automatically disables color decoding when it detects no color modulation. When this flag is set the color killer is enabled and has shut off color decoding."}, + {V4L2_IN_ST_NO_SYNC, "No synchronization lock."}, + {V4L2_IN_ST_NO_EQU, "No equalizer lock."}, + {V4L2_IN_ST_NO_CARRIER, "Carrier recovery failed."}, + {V4L2_IN_ST_MACROVISION, "Macrovision is an analog copy prevention system mangling the video signal to confuse video recorders. When this flag is set Macrovision has been detected."}, + {V4L2_IN_ST_NO_ACCESS, "Conditional access denied."}, + {V4L2_IN_ST_VTR, "VTR time constant. [?]"}, + {0, NULL} +}; + + static void print_sliced_vbi_cap(struct v4l2_sliced_vbi_cap &cap) { printf("\tType : %s\n", buftype2s(cap.type).c_str());
@@ -2671,6 +2689,11 @@ set_vid_fmt_error: if (ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0) printf(" (%s)", vin.name); printf("\n"); + printf("Signal status: "); + if (vin.status) + printf("%s\n", flags2s(vin.status,status_def).c_str()); + else + printf("Signal detected or detection unavailable\n"); } }
Quoted 21 lines · On Friday 23 October 2009 15:38:03 Sigmund Augdal wrote:
Quoted 20 lines · Sigmund Augdal
Quoted 19 lines · Hans Verkuil
Quoted 11 lines
The attach patch modifies v4l2-ctl -I to also output signal status as detected by the driver/hardware. This info is available in the status field of the data returned by
VIDIOC_ENUMINPUTwhich v4l2-ctl -I already calls. The strings are copied from the v4l2 api specification and could perhaps be modified a bit to fit the application.Best regards
Sigmund Augdal
Hi Sigmund,
This doesn't work right: the status field is a bitmask, so multiple bits can be set at the same time. So a switch is not the right choice for that. Look at some of the other functions to print bitmasks in v4l2-ctl.cpp for ideas on how to implement this properly.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
But it will be nice to have this in v4l2-ctl!
Right, I realized this shortly after sending. I'll take a look at this today. However, I'm unsure how to handle the value 0. It seems this is used both for "signal detected and everything is ok" and "driver has no clue if there is a signal or not". Any feedback welcome.
And again, this time with the attachment.
Hi Sigmund,
Thanks for these patches. I've added them to my v4l-dvb tree and will post a pull request for them soon.
I did some cleanup of the enuminput code as it was a bit inconsistent with other parts of the v4l2-ctl code and I took the opportunity to improve the printing of the std field in enum_input/output.
Regards,
Hans
Quoted 19 lines
Best regards
Sigmund Augdal
Quoted 14 lines
Best regards
Sigmund Augdal
Quoted 9 lines
Regards,
Hans
--
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom