]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: cec: expose the new connector info API
authorDariusz Marcinkiewicz <darekm@google.com>
Fri, 23 Aug 2019 12:20:58 +0000 (09:20 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 1 Oct 2019 20:19:41 +0000 (17:19 -0300)
Until now the connector info API was a kernel-internal API only.
This moves it to the public API and adds the new ioctl to retrieve
this information.

Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/cec/cec-adap.c
drivers/media/cec/cec-api.c
drivers/media/cec/cec-core.c
include/media/cec.h
include/uapi/linux/cec.h

index 284f9b845161a185f8815705c0e0220916a490e5..9340435a94a095d77bddcb12b6331940878d1c8e 100644 (file)
@@ -319,6 +319,8 @@ static void cec_post_state_event(struct cec_adapter *adap)
 
        ev.state_change.phys_addr = adap->phys_addr;
        ev.state_change.log_addr_mask = adap->log_addrs.log_addr_mask;
+       ev.state_change.have_conn_info =
+               adap->conn_info.type != CEC_CONNECTOR_TYPE_NO_CONNECTOR;
        cec_queue_event(adap, &ev);
 }
 
index 12d6764844724ccc0b85126e52a9882e189413cf..17d1cb2e5f976db01102004ef37e5e494111de7d 100644 (file)
@@ -187,6 +187,21 @@ static long cec_adap_s_log_addrs(struct cec_adapter *adap, struct cec_fh *fh,
        return 0;
 }
 
+static long cec_adap_g_connector_info(struct cec_adapter *adap,
+                                     struct cec_log_addrs __user *parg)
+{
+       int ret = 0;
+
+       if (!(adap->capabilities & CEC_CAP_CONNECTOR_INFO))
+               return -ENOTTY;
+
+       mutex_lock(&adap->lock);
+       if (copy_to_user(parg, &adap->conn_info, sizeof(adap->conn_info)))
+               ret = -EFAULT;
+       mutex_unlock(&adap->lock);
+       return ret;
+}
+
 static long cec_transmit(struct cec_adapter *adap, struct cec_fh *fh,
                         bool block, struct cec_msg __user *parg)
 {
@@ -506,6 +521,9 @@ static long cec_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        case CEC_ADAP_S_LOG_ADDRS:
                return cec_adap_s_log_addrs(adap, fh, block, parg);
 
+       case CEC_ADAP_G_CONNECTOR_INFO:
+               return cec_adap_g_connector_info(adap, parg);
+
        case CEC_TRANSMIT:
                return cec_transmit(adap, fh, block, parg);
 
@@ -578,6 +596,8 @@ static int cec_open(struct inode *inode, struct file *filp)
        /* Queue up initial state events */
        ev.state_change.phys_addr = adap->phys_addr;
        ev.state_change.log_addr_mask = adap->log_addrs.log_addr_mask;
+       ev.state_change.have_conn_info =
+               adap->conn_info.type != CEC_CONNECTOR_TYPE_NO_CONNECTOR;
        cec_queue_event_fh(fh, &ev, 0);
 #ifdef CONFIG_CEC_PIN
        if (adap->pin && adap->pin->ops->read_hpd) {
index 9c610e1e99b84e2ebceaec5fb5b9ca2015bbf75f..db7adffcdc76f9c5e901f8cf621f54b7a0a52226 100644 (file)
@@ -257,11 +257,6 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
        struct cec_adapter *adap;
        int res;
 
-       /*
-        * Disable this capability until the connector info public API
-        * is ready.
-        */
-       caps &= ~CEC_CAP_CONNECTOR_INFO;
 #ifndef CONFIG_MEDIA_CEC_RC
        caps &= ~CEC_CAP_RC;
 #endif
index 4d59387bc61b1ba26d0f9fd2dad5b4e4f34c16df..0a4f69cc9dd476759fb20b1c25480b5907fe3399 100644 (file)
@@ -18,9 +18,6 @@
 #include <linux/cec-funcs.h>
 #include <media/rc-core.h>
 
-/* CEC_ADAP_G_CONNECTOR_INFO is available */
-#define CEC_CAP_CONNECTOR_INFO (1 << 8)
-
 #define CEC_CAP_DEFAULTS (CEC_CAP_LOG_ADDRS | CEC_CAP_TRANSMIT | \
                          CEC_CAP_PASSTHROUGH | CEC_CAP_RC)
 
@@ -147,34 +144,6 @@ struct cec_adap_ops {
  */
 #define CEC_MAX_MSG_TX_QUEUE_SZ                (18 * 1)
 
-/**
- * struct cec_drm_connector_info - tells which drm connector is
- * associated with the CEC adapter.
- * @card_no: drm card number
- * @connector_id: drm connector ID
- */
-struct cec_drm_connector_info {
-       __u32 card_no;
-       __u32 connector_id;
-};
-
-#define CEC_CONNECTOR_TYPE_NO_CONNECTOR        0
-#define CEC_CONNECTOR_TYPE_DRM         1
-
-/**
- * struct cec_connector_info - tells if and which connector is
- * associated with the CEC adapter.
- * @type: connector type (if any)
- * @drm: drm connector info
- */
-struct cec_connector_info {
-       __u32 type;
-       union {
-               struct cec_drm_connector_info drm;
-               __u32 raw[16];
-       };
-};
-
 struct cec_adapter {
        struct module *owner;
        char name[32];
index 7a5d843af8c9868d11a9cd5a083aac60abd1290f..7d1a06c524696739beb715eaa6ce4703a01d12a5 100644 (file)
@@ -317,6 +317,8 @@ static inline int cec_is_unconfigured(__u16 log_addr_mask)
 #define CEC_CAP_NEEDS_HPD      (1 << 6)
 /* Hardware can monitor CEC pin transitions */
 #define CEC_CAP_MONITOR_PIN    (1 << 7)
+/* CEC_ADAP_G_CONNECTOR_INFO is available */
+#define CEC_CAP_CONNECTOR_INFO (1 << 8)
 
 /**
  * struct cec_caps - CEC capabilities structure.
@@ -375,6 +377,34 @@ struct cec_log_addrs {
 /* CDC-Only device: supports only CDC messages */
 #define CEC_LOG_ADDRS_FL_CDC_ONLY              (1 << 2)
 
+/**
+ * struct cec_drm_connector_info - tells which drm connector is
+ * associated with the CEC adapter.
+ * @card_no: drm card number
+ * @connector_id: drm connector ID
+ */
+struct cec_drm_connector_info {
+       __u32 card_no;
+       __u32 connector_id;
+};
+
+#define CEC_CONNECTOR_TYPE_NO_CONNECTOR        0
+#define CEC_CONNECTOR_TYPE_DRM         1
+
+/**
+ * struct cec_connector_info - tells if and which connector is
+ * associated with the CEC adapter.
+ * @type: connector type (if any)
+ * @drm: drm connector info
+ */
+struct cec_connector_info {
+       __u32 type;
+       union {
+               struct cec_drm_connector_info drm;
+               __u32 raw[16];
+       };
+};
+
 /* Events */
 
 /* Event that occurs when the adapter state changes */
@@ -398,10 +428,17 @@ struct cec_log_addrs {
  * struct cec_event_state_change - used when the CEC adapter changes state.
  * @phys_addr: the current physical address
  * @log_addr_mask: the current logical address mask
+ * @have_conn_info: if non-zero, then HDMI connector information is available.
+ *     This field is only valid if CEC_CAP_CONNECTOR_INFO is set. If that
+ *     capability is set and @have_conn_info is zero, then that indicates
+ *     that the HDMI connector device is not instantiated, either because
+ *     the HDMI driver is still configuring the device or because the HDMI
+ *     device was unbound.
  */
 struct cec_event_state_change {
        __u16 phys_addr;
        __u16 log_addr_mask;
+       __u16 have_conn_info;
 };
 
 /**
@@ -476,6 +513,9 @@ struct cec_event {
 #define CEC_G_MODE             _IOR('a',  8, __u32)
 #define CEC_S_MODE             _IOW('a',  9, __u32)
 
+/* Get the connector info */
+#define CEC_ADAP_G_CONNECTOR_INFO _IOR('a',  10, struct cec_connector_info)
+
 /*
  * The remainder of this header defines all CEC messages and operands.
  * The format matters since it the cec-ctl utility parses it to generate