media: vivid: add instance number to input/output names

Add the instance number before the input or output number.
So "HDMI 1" becomes "HDMI 000-1".

This is helps identifying which input or output belongs to
which vivid instance.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Hans Verkuil 2024-06-24 12:53:00 +03:00
parent 17763960b1
commit 3d023ff2ef
2 changed files with 12 additions and 12 deletions

View File

@ -1073,13 +1073,13 @@ int vidioc_enum_input(struct file *file, void *priv,
inp->type = V4L2_INPUT_TYPE_CAMERA;
switch (dev->input_type[inp->index]) {
case WEBCAM:
snprintf(inp->name, sizeof(inp->name), "Webcam %u",
dev->input_name_counter[inp->index]);
snprintf(inp->name, sizeof(inp->name), "Webcam %03u-%u",
dev->inst, dev->input_name_counter[inp->index]);
inp->capabilities = 0;
break;
case TV:
snprintf(inp->name, sizeof(inp->name), "TV %u",
dev->input_name_counter[inp->index]);
snprintf(inp->name, sizeof(inp->name), "TV %03u-%u",
dev->inst, dev->input_name_counter[inp->index]);
inp->type = V4L2_INPUT_TYPE_TUNER;
inp->std = V4L2_STD_ALL;
if (dev->has_audio_inputs)
@ -1087,16 +1087,16 @@ int vidioc_enum_input(struct file *file, void *priv,
inp->capabilities = V4L2_IN_CAP_STD;
break;
case SVID:
snprintf(inp->name, sizeof(inp->name), "S-Video %u",
dev->input_name_counter[inp->index]);
snprintf(inp->name, sizeof(inp->name), "S-Video %03u-%u",
dev->inst, dev->input_name_counter[inp->index]);
inp->std = V4L2_STD_ALL;
if (dev->has_audio_inputs)
inp->audioset = (1 << ARRAY_SIZE(vivid_audio_inputs)) - 1;
inp->capabilities = V4L2_IN_CAP_STD;
break;
case HDMI:
snprintf(inp->name, sizeof(inp->name), "HDMI %u",
dev->input_name_counter[inp->index]);
snprintf(inp->name, sizeof(inp->name), "HDMI %03u-%u",
dev->inst, dev->input_name_counter[inp->index]);
inp->capabilities = V4L2_IN_CAP_DV_TIMINGS;
if (dev->edid_blocks == 0 ||
dev->dv_timings_signal_mode[dev->input] == NO_SIGNAL)

View File

@ -966,16 +966,16 @@ int vidioc_enum_output(struct file *file, void *priv,
out->type = V4L2_OUTPUT_TYPE_ANALOG;
switch (dev->output_type[out->index]) {
case SVID:
snprintf(out->name, sizeof(out->name), "S-Video %u",
dev->output_name_counter[out->index]);
snprintf(out->name, sizeof(out->name), "S-Video %03u-%u",
dev->inst, dev->output_name_counter[out->index]);
out->std = V4L2_STD_ALL;
if (dev->has_audio_outputs)
out->audioset = (1 << ARRAY_SIZE(vivid_audio_outputs)) - 1;
out->capabilities = V4L2_OUT_CAP_STD;
break;
case HDMI:
snprintf(out->name, sizeof(out->name), "HDMI %u",
dev->output_name_counter[out->index]);
snprintf(out->name, sizeof(out->name), "HDMI %03u-%u",
dev->inst, dev->output_name_counter[out->index]);
out->capabilities = V4L2_OUT_CAP_DV_TIMINGS;
break;
}