Skip to contentSkip to conversation

media: vivid: fix disappearing <Vendor Command With ID> messages

PATCH In review Hans Verkuil 1 participant 2 messages Sep 8, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: vivid: fix disappearing <Vendor Command With ID> messages

The vivid driver supports the <Vendor Command With ID> message, but if the Vendor ID of the received message didn't match the Vendor ID of the CEC Adapter, then it ignores it (good) and returns 0 (bad).

It should return -ENOMSG to indicate that other followers should be asked to handle it. Return code 0 means that the driver handled it, which is wrong in this case.

As a result, userspace followers never get the chance to process such a message.

Refactor the code a bit to have the function return -ENOMSG at the end, drop the default case, and ensure that the message handlers return 0.

That way 0 is only returned if the message is actually handled in the vivid_received() function.

Fixes 812765cd6954 ("media: vivid: add <Vendor Command With ID> support")
---
 drivers/media/test-drivers/vivid/vivid-cec.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/media/test-drivers/vivid/vivid-cec.c +5 -7
index 356a988dd6a1..2d15fdd5d999 100644
@@ -327,7 +327,7 @@ static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 		char osd[14];
 
 		if (!cec_is_sink(adap))
-			return -ENOMSG;
+			break;
 		cec_ops_set_osd_string(msg, &disp_ctl, osd);
 		switch (disp_ctl) {
 		case CEC_OP_DISP_CTL_DEFAULT:
@@ -348,7 +348,7 @@ static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 			cec_transmit_msg(adap, &reply, false);
 			break;
 		}
-		break;
+		return 0;
 	}
 	case CEC_MSG_VENDOR_COMMAND_WITH_ID: {
 		u32 vendor_id;
@@ -379,7 +379,7 @@ static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 		if (size == 1) {
 			// Ignore even op values
 			if (!(vendor_cmd[0] & 1))
-				break;
+				return 0;
 			reply.len = msg->len;
 			memcpy(reply.msg + 1, msg->msg + 1, msg->len - 1);
 			reply.msg[msg->len - 1]++;
@@ -388,12 +388,10 @@ static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 					      CEC_OP_ABORT_INVALID_OP);
 		}
 		cec_transmit_msg(adap, &reply, false);
-		break;
+		return 0;
 	}
-	default:
-		return -ENOMSG;
 	}
-	return 0;
+	return -ENOMSG;
 }
 
 static const struct cec_adap_ops vivid_cec_adap_ops = {
Signature · 1 line
2.47.2
#1 lore raw
Quoted 8 lines · Hans Verkuil

The vivid driver supports the <Vendor Command With ID> message, but if the Vendor ID of the received message didn't match the Vendor ID of the CEC Adapter, then it ignores it (good) and returns 0 (bad).

It should return -ENOMSG to indicate that other followers should be asked to handle it. Return code 0 means that the driver handled it, which is wrong in this case.

Quoted 8 lines

As a result, userspace followers never get the chance to process such a message.

Refactor the code a bit to have the function return -ENOMSG at the end, drop the default case, and ensure that the message handlers return 0.

That way 0 is only returned if the message is actually handled in the vivid_received() function.

Because of this change, the cec-compliance utility also needs to be changed.

The patch for that is here:

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

So once this patch is merged, that patch for v4l-utils also must be merged, otherwise the virtme tests will fail in CI.

The CI pipeline for this vivid patch and that uses the fixed cec-compliance which is found in this v4l-utils branch:

https://git.linuxtv.org/hverkuil/v4l-utils.git/log/?h=cec-fix

is here:

https://gitlab.freedesktop.org/linux-media/users/hverkuil/-/pipelines/1505397

Just to show that it passes.

Regards,

Hans

Quoted 54 lines
Fixes 812765cd6954 ("media: vivid: add <Vendor Command With ID> support")
---
 drivers/media/test-drivers/vivid/vivid-cec.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/media/test-drivers/vivid/vivid-cec.c +5 -7
index 356a988dd6a1..2d15fdd5d999 100644
@@ -327,7 +327,7 @@ static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 		char osd[14];
 
 		if (!cec_is_sink(adap))
-			return -ENOMSG;
+			break;
 		cec_ops_set_osd_string(msg, &disp_ctl, osd);
 		switch (disp_ctl) {
 		case CEC_OP_DISP_CTL_DEFAULT:
@@ -348,7 +348,7 @@ static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 			cec_transmit_msg(adap, &reply, false);
 			break;
 		}
-		break;
+		return 0;
 	}
 	case CEC_MSG_VENDOR_COMMAND_WITH_ID: {
 		u32 vendor_id;
@@ -379,7 +379,7 @@ static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 		if (size == 1) {
 			// Ignore even op values
 			if (!(vendor_cmd[0] & 1))
-				break;
+				return 0;
 			reply.len = msg->len;
 			memcpy(reply.msg + 1, msg->msg + 1, msg->len - 1);
 			reply.msg[msg->len - 1]++;
@@ -388,12 +388,10 @@ static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 					      CEC_OP_ABORT_INVALID_OP);
 		}
 		cec_transmit_msg(adap, &reply, false);
-		break;
+		return 0;
 	}
-	default:
-		return -ENOMSG;
 	}
-	return 0;
+	return -ENOMSG;
 }
 
 static const struct cec_adap_ops vivid_cec_adap_ops = {