* [PATCH] drm/vc4: hdmi: Remove drm_encoder->crtc usage
@ 2021-07-07 14:19 Maxime Ripard
2021-07-07 15:35 ` Thomas Zimmermann
0 siblings, 1 reply; 3+ messages in thread
From: Maxime Ripard @ 2021-07-07 14:19 UTC (permalink / raw)
To: dri-devel, Maarten Lankhorst, Thomas Zimmermann, Maxime Ripard,
Daniel Vetter, David Airlie
Cc: Nicolas Saenz Julienne, Dom Cobley, Tim Gover, Dave Stevenson,
bcm-kernel-feedback-list, linux-rpi-kernel, Phil Elwell
The drm_encoder crtc pointer isn't really fit for an atomic driver,
let's rely on the connector state instead.
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
drivers/gpu/drm/vc4/vc4_hdmi.c | 39 ++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index aab1b36ceb3c..dbd762f41cad 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -435,7 +435,7 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
struct drm_connector *connector = &vc4_hdmi->connector;
struct drm_connector_state *cstate = connector->state;
- struct drm_crtc *crtc = encoder->crtc;
+ struct drm_crtc *crtc = cstate->crtc;
const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
union hdmi_infoframe frame;
int ret;
@@ -545,8 +545,11 @@ static bool vc4_hdmi_supports_scrambling(struct drm_encoder *encoder,
static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
{
- struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
+ struct drm_connector *connector = &vc4_hdmi->connector;
+ struct drm_connector_state *cstate = connector->state;
+ struct drm_crtc *crtc = cstate->crtc;
+ struct drm_display_mode *mode = &crtc->state->adjusted_mode;
if (!vc4_hdmi_supports_scrambling(encoder, mode))
return;
@@ -567,17 +570,18 @@ static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder)
{
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
- struct drm_crtc *crtc = encoder->crtc;
+ struct drm_connector *connector = &vc4_hdmi->connector;
+ struct drm_connector_state *cstate = connector->state;
/*
- * At boot, encoder->crtc will be NULL. Since we don't know the
+ * At boot, connector->state will be NULL. Since we don't know the
* state of the scrambler and in order to avoid any
* inconsistency, let's disable it all the time.
*/
- if (crtc && !vc4_hdmi_supports_scrambling(encoder, &crtc->mode))
+ if (cstate && !vc4_hdmi_supports_scrambling(encoder, &cstate->crtc->mode))
return;
- if (crtc && !vc4_hdmi_mode_needs_scrambling(&crtc->mode))
+ if (cstate && !vc4_hdmi_mode_needs_scrambling(&cstate->crtc->mode))
return;
if (delayed_work_pending(&vc4_hdmi->scrambling_work))
@@ -898,7 +902,9 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
vc4_hdmi_encoder_get_connector_state(encoder, state);
struct vc4_hdmi_connector_state *vc4_conn_state =
conn_state_to_vc4_hdmi_conn_state(conn_state);
- struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
+ struct drm_crtc_state *crtc_state =
+ drm_atomic_get_new_crtc_state(state, conn_state->crtc);
+ struct drm_display_mode *mode = &crtc_state->adjusted_mode;
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
unsigned long bvb_rate, pixel_rate, hsm_rate;
int ret;
@@ -983,7 +989,11 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder,
struct drm_atomic_state *state)
{
- struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
+ struct drm_connector_state *conn_state =
+ vc4_hdmi_encoder_get_connector_state(encoder, state);
+ struct drm_crtc_state *crtc_state =
+ drm_atomic_get_new_crtc_state(state, conn_state->crtc);
+ struct drm_display_mode *mode = &crtc_state->adjusted_mode;
struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
@@ -1006,7 +1016,11 @@ static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder,
static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,
struct drm_atomic_state *state)
{
- struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
+ struct drm_connector_state *conn_state =
+ vc4_hdmi_encoder_get_connector_state(encoder, state);
+ struct drm_crtc_state *crtc_state =
+ drm_atomic_get_new_crtc_state(state, conn_state->crtc);
+ struct drm_display_mode *mode = &crtc_state->adjusted_mode;
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
bool hsync_pos = mode->flags & DRM_MODE_FLAG_PHSYNC;
@@ -1192,8 +1206,8 @@ static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *vc4_hdmi)
static void vc4_hdmi_set_n_cts(struct vc4_hdmi *vc4_hdmi)
{
- struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
- struct drm_crtc *crtc = encoder->crtc;
+ struct drm_connector *connector = &vc4_hdmi->connector;
+ struct drm_crtc *crtc = connector->state->crtc;
const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
u32 samplerate = vc4_hdmi->audio.samplerate;
u32 n, cts;
@@ -1228,7 +1242,6 @@ static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
- struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
struct drm_connector *connector = &vc4_hdmi->connector;
int ret;
@@ -1241,7 +1254,7 @@ static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream,
* If the HDMI encoder hasn't probed, or the encoder is
* currently in DVI mode, treat the codec dai as missing.
*/
- if (!encoder->crtc || !(HDMI_READ(HDMI_RAM_PACKET_CONFIG) &
+ if (!connector->state || !(HDMI_READ(HDMI_RAM_PACKET_CONFIG) &
VC4_HDMI_RAM_PACKET_ENABLE))
return -ENODEV;
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/vc4: hdmi: Remove drm_encoder->crtc usage
2021-07-07 14:19 [PATCH] drm/vc4: hdmi: Remove drm_encoder->crtc usage Maxime Ripard
@ 2021-07-07 15:35 ` Thomas Zimmermann
2021-07-15 9:09 ` Maxime Ripard
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Zimmermann @ 2021-07-07 15:35 UTC (permalink / raw)
To: Maxime Ripard, dri-devel, Maarten Lankhorst, Daniel Vetter, David Airlie
Cc: Nicolas Saenz Julienne, Dom Cobley, Tim Gover, Dave Stevenson,
bcm-kernel-feedback-list, linux-rpi-kernel, Phil Elwell
[-- Attachment #1.1: Type: text/plain, Size: 6480 bytes --]
Am 07.07.21 um 16:19 schrieb Maxime Ripard:
> The drm_encoder crtc pointer isn't really fit for an atomic driver,
> let's rely on the connector state instead.
>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> drivers/gpu/drm/vc4/vc4_hdmi.c | 39 ++++++++++++++++++++++------------
> 1 file changed, 26 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> index aab1b36ceb3c..dbd762f41cad 100644
> --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> @@ -435,7 +435,7 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
> struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
> struct drm_connector *connector = &vc4_hdmi->connector;
> struct drm_connector_state *cstate = connector->state;
> - struct drm_crtc *crtc = encoder->crtc;
> + struct drm_crtc *crtc = cstate->crtc;
> const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
> union hdmi_infoframe frame;
> int ret;
> @@ -545,8 +545,11 @@ static bool vc4_hdmi_supports_scrambling(struct drm_encoder *encoder,
>
> static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
> {
> - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
> + struct drm_connector *connector = &vc4_hdmi->connector;
> + struct drm_connector_state *cstate = connector->state;
> + struct drm_crtc *crtc = cstate->crtc;
> + struct drm_display_mode *mode = &crtc->state->adjusted_mode;
>
> if (!vc4_hdmi_supports_scrambling(encoder, mode))
> return;
> @@ -567,17 +570,18 @@ static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
> static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder)
> {
> struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
> - struct drm_crtc *crtc = encoder->crtc;
> + struct drm_connector *connector = &vc4_hdmi->connector;
> + struct drm_connector_state *cstate = connector->state;
>
> /*
> - * At boot, encoder->crtc will be NULL. Since we don't know the
> + * At boot, connector->state will be NULL. Since we don't know the
> * state of the scrambler and in order to avoid any
> * inconsistency, let's disable it all the time.
> */
> - if (crtc && !vc4_hdmi_supports_scrambling(encoder, &crtc->mode))
> + if (cstate && !vc4_hdmi_supports_scrambling(encoder, &cstate->crtc->mode))
> return;
>
> - if (crtc && !vc4_hdmi_mode_needs_scrambling(&crtc->mode))
> + if (cstate && !vc4_hdmi_mode_needs_scrambling(&cstate->crtc->mode))
> return;
>
> if (delayed_work_pending(&vc4_hdmi->scrambling_work))
> @@ -898,7 +902,9 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
> vc4_hdmi_encoder_get_connector_state(encoder, state);
> struct vc4_hdmi_connector_state *vc4_conn_state =
> conn_state_to_vc4_hdmi_conn_state(conn_state);
> - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> + struct drm_crtc_state *crtc_state =
> + drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> + struct drm_display_mode *mode = &crtc_state->adjusted_mode;
> struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
> unsigned long bvb_rate, pixel_rate, hsm_rate;
> int ret;
> @@ -983,7 +989,11 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
> static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder,
> struct drm_atomic_state *state)
> {
> - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> + struct drm_connector_state *conn_state =
> + vc4_hdmi_encoder_get_connector_state(encoder, state);
> + struct drm_crtc_state *crtc_state =
> + drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> + struct drm_display_mode *mode = &crtc_state->adjusted_mode;
> struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
> struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
>
> @@ -1006,7 +1016,11 @@ static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder,
> static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,
> struct drm_atomic_state *state)
> {
> - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
> + struct drm_connector_state *conn_state =
> + vc4_hdmi_encoder_get_connector_state(encoder, state);
> + struct drm_crtc_state *crtc_state =
> + drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> + struct drm_display_mode *mode = &crtc_state->adjusted_mode;
> struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
> struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
> bool hsync_pos = mode->flags & DRM_MODE_FLAG_PHSYNC;
> @@ -1192,8 +1206,8 @@ static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *vc4_hdmi)
>
> static void vc4_hdmi_set_n_cts(struct vc4_hdmi *vc4_hdmi)
> {
> - struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
> - struct drm_crtc *crtc = encoder->crtc;
> + struct drm_connector *connector = &vc4_hdmi->connector;
> + struct drm_crtc *crtc = connector->state->crtc;
> const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
> u32 samplerate = vc4_hdmi->audio.samplerate;
> u32 n, cts;
> @@ -1228,7 +1242,6 @@ static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream,
> struct snd_soc_dai *dai)
> {
> struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
> - struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
> struct drm_connector *connector = &vc4_hdmi->connector;
> int ret;
>
> @@ -1241,7 +1254,7 @@ static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream,
> * If the HDMI encoder hasn't probed, or the encoder is
> * currently in DVI mode, treat the codec dai as missing.
> */
> - if (!encoder->crtc || !(HDMI_READ(HDMI_RAM_PACKET_CONFIG) &
> + if (!connector->state || !(HDMI_READ(HDMI_RAM_PACKET_CONFIG) &
> VC4_HDMI_RAM_PACKET_ENABLE))
> return -ENODEV;
>
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/vc4: hdmi: Remove drm_encoder->crtc usage
2021-07-07 15:35 ` Thomas Zimmermann
@ 2021-07-15 9:09 ` Maxime Ripard
0 siblings, 0 replies; 3+ messages in thread
From: Maxime Ripard @ 2021-07-15 9:09 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: Nicolas Saenz Julienne, Dom Cobley, Tim Gover, Dave Stevenson,
David Airlie, dri-devel, bcm-kernel-feedback-list,
linux-rpi-kernel, Daniel Vetter, Phil Elwell
[-- Attachment #1: Type: text/plain, Size: 388 bytes --]
On Wed, Jul 07, 2021 at 05:35:53PM +0200, Thomas Zimmermann wrote:
>
>
> Am 07.07.21 um 16:19 schrieb Maxime Ripard:
> > The drm_encoder crtc pointer isn't really fit for an atomic driver,
> > let's rely on the connector state instead.
> >
> > Signed-off-by: Maxime Ripard <maxime@cerno.tech>
>
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Applied, thanks
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-15 9:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 14:19 [PATCH] drm/vc4: hdmi: Remove drm_encoder->crtc usage Maxime Ripard
2021-07-07 15:35 ` Thomas Zimmermann
2021-07-15 9:09 ` Maxime Ripard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.