media: cros-ec-cec: Support multiple ports in set/get host commands
authorReka Norman <rekanorman@chromium.org>
Fri, 25 Aug 2023 02:43:56 +0000 (12:43 +1000)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 27 Sep 2023 07:39:54 +0000 (09:39 +0200)
Reuse the top four bits of the cmd field to specify the port number.
The reason for doing this as opposed to adding a separate uint8_t field
is it avoids the need to add new versions of these commands. The change
is backwards compatible since these bits were previously always zero, so
the default behaviour is to always operate on port 0.

Signed-off-by: Reka Norman <rekanorman@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/cec/platform/cros-ec/cros-ec-cec.c
include/linux/platform_data/cros_ec_commands.h

index d76a25ae0cf180dc97a81024158183da544b1c3e..e969031e1e0e3699f08b0e288f8c5950532f6ddf 100644 (file)
@@ -118,6 +118,7 @@ static int cros_ec_cec_set_log_addr(struct cec_adapter *adap, u8 logical_addr)
        struct cros_ec_device *cros_ec = cros_ec_cec->cros_ec;
        struct ec_params_cec_set params = {
                .cmd = CEC_CMD_LOGICAL_ADDRESS,
+               .port = port->port_num,
                .val = logical_addr,
        };
        int ret;
@@ -162,6 +163,7 @@ static int cros_ec_cec_adap_enable(struct cec_adapter *adap, bool enable)
        struct cros_ec_device *cros_ec = cros_ec_cec->cros_ec;
        struct ec_params_cec_set params = {
                .cmd = CEC_CMD_ENABLE,
+               .port = port->port_num,
                .val = enable,
        };
        int ret;
index cb2ddd10a6137d053af033112cf8725f5d030c94..e8bb05db360f14f7fa57884ab50eb685581b75a3 100644 (file)
@@ -4457,13 +4457,15 @@ struct ec_params_cec_write {
 /**
  * struct ec_params_cec_set - CEC parameters set
  * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS
+ * @port: CEC port to set the parameter on
  * @val: in case cmd is CEC_CMD_ENABLE, this field can be 0 to disable CEC
  *     or 1 to enable CEC functionality, in case cmd is
  *     CEC_CMD_LOGICAL_ADDRESS, this field encodes the requested logical
  *     address between 0 and 15 or 0xff to unregister
  */
 struct ec_params_cec_set {
-       uint8_t cmd; /* enum cec_command */
+       uint8_t cmd : 4; /* enum cec_command */
+       uint8_t port : 4;
        uint8_t val;
 } __ec_align1;
 
@@ -4473,9 +4475,11 @@ struct ec_params_cec_set {
 /**
  * struct ec_params_cec_get - CEC parameters get
  * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS
+ * @port: CEC port to get the parameter on
  */
 struct ec_params_cec_get {
-       uint8_t cmd; /* enum cec_command */
+       uint8_t cmd : 4; /* enum cec_command */
+       uint8_t port : 4;
 } __ec_align1;
 
 /**