On Fri Jul 10 13:07:34 2026 +0200, Hans Verkuil wrote:
> If claiming a logical address fails, then set the
> CEC_LOG_ADDRS_FL_CONFIG_FAILED flag. This makes it possible for
> userspace to detect this corner case.
> 
> Signed-off-by: Hans Verkuil <[email protected]>
> Signed-off-by: Mauro Carvalho Chehab <[email protected]>

Patch committed.

Thanks,
Mauro Carvalho Chehab

 Documentation/userspace-api/media/cec/cec-ioc-adap-g-log-addrs.rst | 7 +++++++
 drivers/media/cec/core/cec-adap.c                                  | 3 +++
 include/uapi/linux/cec.h                                           | 2 ++
 3 files changed, 12 insertions(+)

---

diff --git a/Documentation/userspace-api/media/cec/cec-ioc-adap-g-log-addrs.rst 
b/Documentation/userspace-api/media/cec/cec-ioc-adap-g-log-addrs.rst
index f3293a589dd6..8397bf573798 100644
--- a/Documentation/userspace-api/media/cec/cec-ioc-adap-g-log-addrs.rst
+++ b/Documentation/userspace-api/media/cec/cec-ioc-adap-g-log-addrs.rst
@@ -185,6 +185,13 @@ logical address types are already defined will return with 
error ``EBUSY``.
        are CEC devices that can only handle CDC messages.
 
        All other messages are ignored.
+    * .. _`CEC-LOG-ADDRS-FL-CONFIG-FAILED`:
+
+      - ``CEC_LOG_ADDRS_FL_CONFIG_FAILED``
+      - 8
+      - If this flag is set, then the CEC device failed to claim a free logical
+        address and is in the unconfigured state. This can never happen if
+       ``CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK`` was set as well.
 
 .. tabularcolumns:: |p{7.8cm}|p{1.0cm}|p{8.5cm}|
 
diff --git a/drivers/media/cec/core/cec-adap.c 
b/drivers/media/cec/core/cec-adap.c
index 4d14186bfef6..774bf9099183 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -1482,6 +1482,7 @@ static int cec_config_thread_func(void *arg)
        dprintk(1, "physical address: %x.%x.%x.%x, claim %d logical 
addresses\n",
                cec_phys_addr_exp(adap->phys_addr), las->num_log_addrs);
        las->log_addr_mask = 0;
+       las->flags &= ~CEC_LOG_ADDRS_FL_CONFIG_FAILED;
 
        if (las->log_addr_type[0] == CEC_LOG_ADDR_TYPE_UNREGISTERED)
                goto configured;
@@ -1614,6 +1615,8 @@ configured:
 unconfigure:
        for (i = 0; i < las->num_log_addrs; i++)
                las->log_addr[i] = CEC_LOG_ADDR_INVALID;
+       if (adap->phys_addr != CEC_PHYS_ADDR_INVALID)
+               las->flags |= CEC_LOG_ADDRS_FL_CONFIG_FAILED;
        cec_adap_unconfigure(adap);
        adap->is_configuring = false;
        adap->must_reconfigure = false;
diff --git a/include/uapi/linux/cec.h b/include/uapi/linux/cec.h
index 81a05c9c0706..fdfc97a6e4ec 100644
--- a/include/uapi/linux/cec.h
+++ b/include/uapi/linux/cec.h
@@ -403,6 +403,8 @@ struct cec_log_addrs {
 #define CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU     (1 << 1)
 /* CDC-Only device: supports only CDC messages */
 #define CEC_LOG_ADDRS_FL_CDC_ONLY              (1 << 2)
+/* Configuration failed */
+#define CEC_LOG_ADDRS_FL_CONFIG_FAILED         (1 << 3)
 
 /**
  * struct cec_drm_connector_info - tells which drm connector is
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to