drm/vc4: add extcon hdmi connection uevent
[platform/kernel/linux-rpi.git] / drivers / gpu / drm / vc4 / vc4_hdmi.h
index 53dd116..2c599db 100644 (file)
@@ -8,22 +8,14 @@
 
 #include "vc4_drv.h"
 
-/* VC4 HDMI encoder KMS struct */
-struct vc4_hdmi_encoder {
-       struct vc4_encoder base;
-       bool hdmi_monitor;
-};
-
-static inline struct vc4_hdmi_encoder *
-to_vc4_hdmi_encoder(struct drm_encoder *encoder)
-{
-       return container_of(encoder, struct vc4_hdmi_encoder, base.base);
-}
-
 struct vc4_hdmi;
 struct vc4_hdmi_register;
 struct vc4_hdmi_connector_state;
 
+#ifdef CONFIG_EXTCON
+struct extcon_dev;
+#endif
+
 enum vc4_hdmi_phy_channel {
        PHY_LANE_0 = 0,
        PHY_LANE_1,
@@ -70,7 +62,8 @@ struct vc4_hdmi_variant {
        /* Callback to get the resources (memory region, interrupts,
         * clocks, etc) for that variant.
         */
-       int (*init_resources)(struct vc4_hdmi *vc4_hdmi);
+       int (*init_resources)(struct drm_device *drm,
+                             struct vc4_hdmi *vc4_hdmi);
 
        /* Callback to reset the HDMI block */
        void (*reset)(struct vc4_hdmi *vc4_hdmi);
@@ -83,7 +76,7 @@ struct vc4_hdmi_variant {
        /* Callback to configure the video timings in the HDMI block */
        void (*set_timings)(struct vc4_hdmi *vc4_hdmi,
                            struct drm_connector_state *state,
-                           struct drm_display_mode *mode);
+                           const struct drm_display_mode *mode);
 
        /* Callback to initialize the PHY according to the connector state */
        void (*phy_init)(struct vc4_hdmi *vc4_hdmi,
@@ -122,6 +115,7 @@ struct vc4_hdmi_audio {
 };
 
 enum vc4_hdmi_output_format {
+       VC4_HDMI_OUTPUT_AUTO,
        VC4_HDMI_OUTPUT_RGB,
        VC4_HDMI_OUTPUT_YUV422,
        VC4_HDMI_OUTPUT_YUV444,
@@ -135,12 +129,13 @@ struct vc4_hdmi {
        struct platform_device *pdev;
        const struct vc4_hdmi_variant *variant;
 
-       struct vc4_hdmi_encoder encoder;
+       struct vc4_encoder encoder;
        struct drm_connector connector;
 
        struct delayed_work scrambling_work;
 
        struct drm_property *broadcast_rgb_property;
+       struct drm_property *output_format_property;
 
        struct i2c_adapter *ddc;
        void __iomem *hdmicore_regs;
@@ -192,15 +187,7 @@ struct vc4_hdmi {
 
        /**
         * @mutex: Mutex protecting the driver access across multiple
-        * frameworks (KMS, ALSA).
-        *
-        * NOTE: While supported, CEC has been left out since
-        * cec_s_phys_addr_from_edid() might call .adap_enable and lead to a
-        * reentrancy issue between .get_modes (or .detect) and .adap_enable.
-        * Since we don't share any state between the CEC hooks and KMS', it's
-        * not a big deal. The only trouble might come from updating the CEC
-        * clock divider which might be affected by a modeset, but CEC should
-        * be resilient to that.
+        * frameworks (KMS, ALSA, CEC).
         */
        struct mutex mutex;
 
@@ -233,6 +220,11 @@ struct vc4_hdmi {
         * for use outside of KMS hooks. Protected by @mutex.
         */
        enum vc4_hdmi_output_format output_format;
+       /**
+        * @requested_output_format: Copy of @vc4_connector_state.requested_output_format
+        * for use outside of KMS hooks. Protected by @mutex.
+        */
+       enum vc4_hdmi_output_format requested_output_format;
 
        /**
         * @broadcast_rgb: Copy of @vc4_connector_state.broadcast_rgb
@@ -247,6 +239,11 @@ struct vc4_hdmi {
        struct debugfs_regset32 phy_regset;
        struct debugfs_regset32 ram_regset;
        struct debugfs_regset32 rm_regset;
+
+#ifdef CONFIG_EXTCON
+       enum drm_connector_status status;
+       struct extcon_dev *edev;
+#endif
 };
 
 static inline struct vc4_hdmi *
@@ -258,8 +255,7 @@ connector_to_vc4_hdmi(struct drm_connector *connector)
 static inline struct vc4_hdmi *
 encoder_to_vc4_hdmi(struct drm_encoder *encoder)
 {
-       struct vc4_hdmi_encoder *_encoder = to_vc4_hdmi_encoder(encoder);
-
+       struct vc4_encoder *_encoder = to_vc4_encoder(encoder);
        return container_of(_encoder, struct vc4_hdmi, encoder);
 }
 
@@ -268,6 +264,7 @@ struct vc4_hdmi_connector_state {
        unsigned long long              pixel_rate;
        unsigned int                    output_bpc;
        enum vc4_hdmi_output_format     output_format;
+       enum vc4_hdmi_output_format     requested_output_format;
        int                             broadcast_rgb;
 };