* Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
2017-05-12 7:31 ` [PATCH] " Daniel Vetter
@ 2017-05-12 11:29 ` Laurent Pinchart
2017-05-15 6:50 ` Daniel Vetter
2017-05-12 12:37 ` Andrzej Hajda
` (3 subsequent siblings)
4 siblings, 1 reply; 35+ messages in thread
From: Laurent Pinchart @ 2017-05-12 11:29 UTC (permalink / raw)
To: dri-devel
Cc: Jose Abreu, Daniel Vetter, Jose Abreu, Alexey Brodkin,
Carlos Palminha
Hi Daniel,
On Friday 12 May 2017 09:31:00 Daniel Vetter wrote:
> From: Jose Abreu <Jose.Abreu@synopsys.com>
>
> This adds a new callback to crtc, encoder and bridge helper functions
> called mode_valid(). This callback shall be implemented if the
> corresponding component has some sort of restriction in the modes
> that can be displayed. A NULL callback implicates that the component
> can display all the modes.
>
> We also change the documentation so that the new and old callbacks
> are correctly documented.
>
> Only the callbacks were implemented to simplify review process,
> following patches will make use of them.
>
> Changes in v2 from Daniel:
> - Update the warning about how modes aren't filtered in atomic_check -
> the heleprs help out a lot more now.
> - Consistenly roll out that warning, crtc/encoder's atomic_check
> missed it.
> - Sprinkle more links all over the place, so it's easier to see where
> this stuff is used and how the differen hooks are related.
> - Note that ->mode_valid is optional everywhere.
> - Explain why the connector's mode_valid is special and does _not_ get
> called in atomic_check.
As commented on v2 (but after you sent this patch), I think we need to
document clearly how mode_valid and mode_fixup should interact. It's very
confusing for driver authors at the moment.
> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> Cc: Jose Abreu <joabreu@synopsys.com>
> Cc: Carlos Palminha <palminha@synopsys.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@linux.ie>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Archit Taneja <architt@codeaurora.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2)
> ---
> include/drm/drm_bridge.h | 31 +++++++++
> include/drm/drm_modeset_helper_vtables.h | 116
> ++++++++++++++++++++++--------- 2 files changed, 114 insertions(+), 33
> deletions(-)
>
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index fdd82fcbf168..f694de756ecf 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -59,6 +59,31 @@ struct drm_bridge_funcs {
> void (*detach)(struct drm_bridge *bridge);
>
> /**
> + * @mode_valid:
> + *
> + * This callback is used to check if a specific mode is valid in this
> + * bridge. This should be implemented if the bridge has some sort of
> + * restriction in the modes it can display. For example, a given
bridge
> + * may be responsible to set a clock value. If the clock can not
> + * produce all the values for the available modes then this callback
> + * can be used to restrict the number of modes to only the ones that
> + * can be displayed.
> + *
> + * This hook is used by the probe helpers to filter the mode list in
> + * drm_helper_probe_single_connector_modes(), and it is used by the
> + * atomic helpers to validate modes supplied by userspace in
> + * drm_atomic_helper_check_modeset().
> + *
> + * This function is optional.
> + *
> + * RETURNS:
> + *
> + * drm_mode_status Enum
> + */
> + enum drm_mode_status (*mode_valid)(struct drm_bridge *crtc,
> + const struct drm_display_mode
*mode);
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate and adjust a mode. The paramater
> @@ -82,6 +107,12 @@ struct drm_bridge_funcs {
> * NOT touch any persistent state (hardware or software) or data
> * structures except the passed in @state parameter.
> *
> + * Also beware that userspace can request its own custom modes,
neither
> + * core nor helpers filter modes to the list of probe modes reported
by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
ensure
> + * that modes are filtered consistently put any bridge constraints and
> + * limits checks into @mode_valid.
> + *
> * RETURNS:
> *
> * True if an acceptable configuration is possible, false if the
modeset
> diff --git a/include/drm/drm_modeset_helper_vtables.h
> b/include/drm/drm_modeset_helper_vtables.h index c01c328f6cc8..91d071ff1232
> 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -106,6 +106,31 @@ struct drm_crtc_helper_funcs {
> void (*commit)(struct drm_crtc *crtc);
>
> /**
> + * @mode_valid:
> + *
> + * This callback is used to check if a specific mode is valid in this
> + * crtc. This should be implemented if the crtc has some sort of
> + * restriction in the modes it can display. For example, a given crtc
> + * may be responsible to set a clock value. If the clock can not
> + * produce all the values for the available modes then this callback
> + * can be used to restrict the number of modes to only the ones that
> + * can be displayed.
> + *
> + * This hook is used by the probe helpers to filter the mode list in
> + * drm_helper_probe_single_connector_modes(), and it is used by the
> + * atomic helpers to validate modes supplied by userspace in
> + * drm_atomic_helper_check_modeset().
> + *
> + * This function is optional.
> + *
> + * RETURNS:
> + *
> + * drm_mode_status Enum
> + */
> + enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
> + const struct drm_display_mode
*mode);
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate a mode. The parameter mode is the
> @@ -132,20 +157,11 @@ struct drm_crtc_helper_funcs {
> * Atomic drivers which need to inspect and adjust more state should
> * instead use the @atomic_check callback.
> *
> - * Also beware that neither core nor helpers filter modes before
> - * passing them to the driver: While the list of modes that is
> - * advertised to userspace is filtered using the
> - * &drm_connector.mode_valid callback, neither the core nor the
helpers
> - * do any filtering on modes passed in from userspace when setting a
> - * mode. It is therefore possible for userspace to pass in a mode that
> - * was previously filtered out using &drm_connector.mode_valid or add
a
> - * custom mode that wasn't probed from EDID or similar to begin with.
> - * Even though this is an advanced feature and rarely used nowadays,
> - * some users rely on being able to specify modes manually so drivers
> - * must be prepared to deal with it. Specifically this means that all
> - * drivers need not only validate modes in &drm_connector.mode_valid
but
> - * also in this or in the &drm_encoder_helper_funcs.mode_fixup
callback
> - * to make sure invalid modes passed in from userspace are rejected.
> + * Also beware that userspace can request its own custom modes,
neither
> + * core nor helpers filter modes to the list of probe modes reported
by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
ensure
> + * that modes are filtered consistently put any CRTC constraints and
> + * limits checks into @mode_valid.
> *
> * RETURNS:
> *
> @@ -341,6 +357,12 @@ struct drm_crtc_helper_funcs {
> * state objects passed-in or assembled in the overall
&drm_atomic_state
> * update tracking structure.
> *
> + * Also beware that userspace can request its own custom modes,
neither
> + * core nor helpers filter modes to the list of probe modes reported
by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
ensure
> + * that modes are filtered consistently put any CRTC constraints and
> + * limits checks into @mode_valid.
> + *
> * RETURNS:
> *
> * 0 on success, -EINVAL if the state or the transition can't be
> @@ -457,6 +479,31 @@ struct drm_encoder_helper_funcs {
> void (*dpms)(struct drm_encoder *encoder, int mode);
>
> /**
> + * @mode_valid:
> + *
> + * This callback is used to check if a specific mode is valid in this
> + * encoder. This should be implemented if the encoder has some sort
> + * of restriction in the modes it can display. For example, a given
> + * encoder may be responsible to set a clock value. If the clock can
> + * not produce all the values for the available modes then this
callback
> + * can be used to restrict the number of modes to only the ones that
> + * can be displayed.
> + *
> + * This hook is used by the probe helpers to filter the mode list in
> + * drm_helper_probe_single_connector_modes(), and it is used by the
> + * atomic helpers to validate modes supplied by userspace in
> + * drm_atomic_helper_check_modeset().
> + *
> + * This function is optional.
> + *
> + * RETURNS:
> + *
> + * drm_mode_status Enum
> + */
> + enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
> + const struct drm_display_mode
*mode);
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate and adjust a mode. The parameter
> @@ -482,21 +529,11 @@ struct drm_encoder_helper_funcs {
> * Atomic drivers which need to inspect and adjust more state should
> * instead use the @atomic_check callback.
> *
> - * Also beware that neither core nor helpers filter modes before
> - * passing them to the driver: While the list of modes that is
> - * advertised to userspace is filtered using the connector's
> - * &drm_connector_helper_funcs.mode_valid callback, neither the core
nor
> - * the helpers do any filtering on modes passed in from userspace when
> - * setting a mode. It is therefore possible for userspace to pass in a
> - * mode that was previously filtered out using
> - * &drm_connector_helper_funcs.mode_valid or add a custom mode that
> - * wasn't probed from EDID or similar to begin with. Even though this
> - * is an advanced feature and rarely used nowadays, some users rely on
> - * being able to specify modes manually so drivers must be prepared to
> - * deal with it. Specifically this means that all drivers need not
only
> - * validate modes in &drm_connector.mode_valid but also in this or in
> - * the &drm_crtc_helper_funcs.mode_fixup callback to make sure
> - * invalid modes passed in from userspace are rejected.
> + * Also beware that userspace can request its own custom modes,
neither
> + * core nor helpers filter modes to the list of probe modes reported
by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
ensure
> + * that modes are filtered consistently put any encoder constraints
and
> + * limits checks into @mode_valid.
> *
> * RETURNS:
> *
> @@ -686,6 +723,12 @@ struct drm_encoder_helper_funcs {
> * state objects passed-in or assembled in the overall
&drm_atomic_state
> * update tracking structure.
> *
> + * Also beware that userspace can request its own custom modes,
neither
> + * core nor helpers filter modes to the list of probe modes reported
by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
ensure
> + * that modes are filtered consistently put any encoder constraints
and
> + * limits checks into @mode_valid.
> + *
> * RETURNS:
> *
> * 0 on success, -EINVAL if the state or the transition can't be
> @@ -795,13 +838,20 @@ struct drm_connector_helper_funcs {
> * (which is usually derived from the EDID data block from the sink).
> * See e.g. drm_helper_probe_single_connector_modes().
> *
> + * This function is optional.
> + *
> * NOTE:
> *
> * This only filters the mode list supplied to userspace in the
> - * GETCONNECOTR IOCTL. Userspace is free to create modes of its own
and
> - * ask the kernel to use them. It this case the atomic helpers or
legacy
> - * CRTC helpers will not call this function. Drivers therefore must
> - * still fully validate any mode passed in in a modeset request.
> + * GETCONNECTOR IOCTL. Compared to
&drm_encoder_helper_funcs.mode_valid,
> + * &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
> + * which are also called by the atomic helpers from
> + * drm_atomic_helper_check_modeset(). This allows userspace to force
and
> + * ignore sink constraint (like the pixel clock limits in the screen's
> + * EDID), which is useful for e.g. testing, or working around a broken
> + * EDID. Any source hardware constraint (which always need to be
> + * enforced) therefore should be checked in one of the above
callbacks,
> + * and not this one here.
> *
> * To avoid races with concurrent connector state updates, the helper
> * libraries always call this with the
&drm_mode_config.connection_mutex
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
2017-05-12 11:29 ` Laurent Pinchart
@ 2017-05-15 6:50 ` Daniel Vetter
0 siblings, 0 replies; 35+ messages in thread
From: Daniel Vetter @ 2017-05-15 6:50 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Jose Abreu, Daniel Vetter, Alexey Brodkin, dri-devel, Jose Abreu,
Carlos Palminha
On Fri, May 12, 2017 at 02:29:30PM +0300, Laurent Pinchart wrote:
> Hi Daniel,
>
> On Friday 12 May 2017 09:31:00 Daniel Vetter wrote:
> > From: Jose Abreu <Jose.Abreu@synopsys.com>
> >
> > This adds a new callback to crtc, encoder and bridge helper functions
> > called mode_valid(). This callback shall be implemented if the
> > corresponding component has some sort of restriction in the modes
> > that can be displayed. A NULL callback implicates that the component
> > can display all the modes.
> >
> > We also change the documentation so that the new and old callbacks
> > are correctly documented.
> >
> > Only the callbacks were implemented to simplify review process,
> > following patches will make use of them.
> >
> > Changes in v2 from Daniel:
> > - Update the warning about how modes aren't filtered in atomic_check -
> > the heleprs help out a lot more now.
> > - Consistenly roll out that warning, crtc/encoder's atomic_check
> > missed it.
> > - Sprinkle more links all over the place, so it's easier to see where
> > this stuff is used and how the differen hooks are related.
> > - Note that ->mode_valid is optional everywhere.
> > - Explain why the connector's mode_valid is special and does _not_ get
> > called in atomic_check.
>
> As commented on v2 (but after you sent this patch), I think we need to
> document clearly how mode_valid and mode_fixup should interact. It's very
> confusing for driver authors at the moment.
I tried to do that here, is it not enough? Note that mode_fixup is kinda
deprecated, in favour of atomic_check. So the equivalence is not as
clear-cut as you seem to think.
-Daniel
>
> > Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> > Cc: Jose Abreu <joabreu@synopsys.com>
> > Cc: Carlos Palminha <palminha@synopsys.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Dave Airlie <airlied@linux.ie>
> > Cc: Andrzej Hajda <a.hajda@samsung.com>
> > Cc: Archit Taneja <architt@codeaurora.org>
> > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2)
> > ---
> > include/drm/drm_bridge.h | 31 +++++++++
> > include/drm/drm_modeset_helper_vtables.h | 116
> > ++++++++++++++++++++++--------- 2 files changed, 114 insertions(+), 33
> > deletions(-)
> >
> > diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> > index fdd82fcbf168..f694de756ecf 100644
> > --- a/include/drm/drm_bridge.h
> > +++ b/include/drm/drm_bridge.h
> > @@ -59,6 +59,31 @@ struct drm_bridge_funcs {
> > void (*detach)(struct drm_bridge *bridge);
> >
> > /**
> > + * @mode_valid:
> > + *
> > + * This callback is used to check if a specific mode is valid in this
> > + * bridge. This should be implemented if the bridge has some sort of
> > + * restriction in the modes it can display. For example, a given
> bridge
> > + * may be responsible to set a clock value. If the clock can not
> > + * produce all the values for the available modes then this callback
> > + * can be used to restrict the number of modes to only the ones that
> > + * can be displayed.
> > + *
> > + * This hook is used by the probe helpers to filter the mode list in
> > + * drm_helper_probe_single_connector_modes(), and it is used by the
> > + * atomic helpers to validate modes supplied by userspace in
> > + * drm_atomic_helper_check_modeset().
> > + *
> > + * This function is optional.
> > + *
> > + * RETURNS:
> > + *
> > + * drm_mode_status Enum
> > + */
> > + enum drm_mode_status (*mode_valid)(struct drm_bridge *crtc,
> > + const struct drm_display_mode
> *mode);
> > +
> > + /**
> > * @mode_fixup:
> > *
> > * This callback is used to validate and adjust a mode. The paramater
> > @@ -82,6 +107,12 @@ struct drm_bridge_funcs {
> > * NOT touch any persistent state (hardware or software) or data
> > * structures except the passed in @state parameter.
> > *
> > + * Also beware that userspace can request its own custom modes,
> neither
> > + * core nor helpers filter modes to the list of probe modes reported
> by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
> ensure
> > + * that modes are filtered consistently put any bridge constraints and
> > + * limits checks into @mode_valid.
> > + *
> > * RETURNS:
> > *
> > * True if an acceptable configuration is possible, false if the
> modeset
> > diff --git a/include/drm/drm_modeset_helper_vtables.h
> > b/include/drm/drm_modeset_helper_vtables.h index c01c328f6cc8..91d071ff1232
> > 100644
> > --- a/include/drm/drm_modeset_helper_vtables.h
> > +++ b/include/drm/drm_modeset_helper_vtables.h
> > @@ -106,6 +106,31 @@ struct drm_crtc_helper_funcs {
> > void (*commit)(struct drm_crtc *crtc);
> >
> > /**
> > + * @mode_valid:
> > + *
> > + * This callback is used to check if a specific mode is valid in this
> > + * crtc. This should be implemented if the crtc has some sort of
> > + * restriction in the modes it can display. For example, a given crtc
> > + * may be responsible to set a clock value. If the clock can not
> > + * produce all the values for the available modes then this callback
> > + * can be used to restrict the number of modes to only the ones that
> > + * can be displayed.
> > + *
> > + * This hook is used by the probe helpers to filter the mode list in
> > + * drm_helper_probe_single_connector_modes(), and it is used by the
> > + * atomic helpers to validate modes supplied by userspace in
> > + * drm_atomic_helper_check_modeset().
> > + *
> > + * This function is optional.
> > + *
> > + * RETURNS:
> > + *
> > + * drm_mode_status Enum
> > + */
> > + enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
> > + const struct drm_display_mode
> *mode);
> > +
> > + /**
> > * @mode_fixup:
> > *
> > * This callback is used to validate a mode. The parameter mode is the
> > @@ -132,20 +157,11 @@ struct drm_crtc_helper_funcs {
> > * Atomic drivers which need to inspect and adjust more state should
> > * instead use the @atomic_check callback.
> > *
> > - * Also beware that neither core nor helpers filter modes before
> > - * passing them to the driver: While the list of modes that is
> > - * advertised to userspace is filtered using the
> > - * &drm_connector.mode_valid callback, neither the core nor the
> helpers
> > - * do any filtering on modes passed in from userspace when setting a
> > - * mode. It is therefore possible for userspace to pass in a mode that
> > - * was previously filtered out using &drm_connector.mode_valid or add
> a
> > - * custom mode that wasn't probed from EDID or similar to begin with.
> > - * Even though this is an advanced feature and rarely used nowadays,
> > - * some users rely on being able to specify modes manually so drivers
> > - * must be prepared to deal with it. Specifically this means that all
> > - * drivers need not only validate modes in &drm_connector.mode_valid
> but
> > - * also in this or in the &drm_encoder_helper_funcs.mode_fixup
> callback
> > - * to make sure invalid modes passed in from userspace are rejected.
> > + * Also beware that userspace can request its own custom modes,
> neither
> > + * core nor helpers filter modes to the list of probe modes reported
> by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
> ensure
> > + * that modes are filtered consistently put any CRTC constraints and
> > + * limits checks into @mode_valid.
> > *
> > * RETURNS:
> > *
> > @@ -341,6 +357,12 @@ struct drm_crtc_helper_funcs {
> > * state objects passed-in or assembled in the overall
> &drm_atomic_state
> > * update tracking structure.
> > *
> > + * Also beware that userspace can request its own custom modes,
> neither
> > + * core nor helpers filter modes to the list of probe modes reported
> by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
> ensure
> > + * that modes are filtered consistently put any CRTC constraints and
> > + * limits checks into @mode_valid.
> > + *
> > * RETURNS:
> > *
> > * 0 on success, -EINVAL if the state or the transition can't be
> > @@ -457,6 +479,31 @@ struct drm_encoder_helper_funcs {
> > void (*dpms)(struct drm_encoder *encoder, int mode);
> >
> > /**
> > + * @mode_valid:
> > + *
> > + * This callback is used to check if a specific mode is valid in this
> > + * encoder. This should be implemented if the encoder has some sort
> > + * of restriction in the modes it can display. For example, a given
> > + * encoder may be responsible to set a clock value. If the clock can
> > + * not produce all the values for the available modes then this
> callback
> > + * can be used to restrict the number of modes to only the ones that
> > + * can be displayed.
> > + *
> > + * This hook is used by the probe helpers to filter the mode list in
> > + * drm_helper_probe_single_connector_modes(), and it is used by the
> > + * atomic helpers to validate modes supplied by userspace in
> > + * drm_atomic_helper_check_modeset().
> > + *
> > + * This function is optional.
> > + *
> > + * RETURNS:
> > + *
> > + * drm_mode_status Enum
> > + */
> > + enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
> > + const struct drm_display_mode
> *mode);
> > +
> > + /**
> > * @mode_fixup:
> > *
> > * This callback is used to validate and adjust a mode. The parameter
> > @@ -482,21 +529,11 @@ struct drm_encoder_helper_funcs {
> > * Atomic drivers which need to inspect and adjust more state should
> > * instead use the @atomic_check callback.
> > *
> > - * Also beware that neither core nor helpers filter modes before
> > - * passing them to the driver: While the list of modes that is
> > - * advertised to userspace is filtered using the connector's
> > - * &drm_connector_helper_funcs.mode_valid callback, neither the core
> nor
> > - * the helpers do any filtering on modes passed in from userspace when
> > - * setting a mode. It is therefore possible for userspace to pass in a
> > - * mode that was previously filtered out using
> > - * &drm_connector_helper_funcs.mode_valid or add a custom mode that
> > - * wasn't probed from EDID or similar to begin with. Even though this
> > - * is an advanced feature and rarely used nowadays, some users rely on
> > - * being able to specify modes manually so drivers must be prepared to
> > - * deal with it. Specifically this means that all drivers need not
> only
> > - * validate modes in &drm_connector.mode_valid but also in this or in
> > - * the &drm_crtc_helper_funcs.mode_fixup callback to make sure
> > - * invalid modes passed in from userspace are rejected.
> > + * Also beware that userspace can request its own custom modes,
> neither
> > + * core nor helpers filter modes to the list of probe modes reported
> by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
> ensure
> > + * that modes are filtered consistently put any encoder constraints
> and
> > + * limits checks into @mode_valid.
> > *
> > * RETURNS:
> > *
> > @@ -686,6 +723,12 @@ struct drm_encoder_helper_funcs {
> > * state objects passed-in or assembled in the overall
> &drm_atomic_state
> > * update tracking structure.
> > *
> > + * Also beware that userspace can request its own custom modes,
> neither
> > + * core nor helpers filter modes to the list of probe modes reported
> by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To
> ensure
> > + * that modes are filtered consistently put any encoder constraints
> and
> > + * limits checks into @mode_valid.
> > + *
> > * RETURNS:
> > *
> > * 0 on success, -EINVAL if the state or the transition can't be
> > @@ -795,13 +838,20 @@ struct drm_connector_helper_funcs {
> > * (which is usually derived from the EDID data block from the sink).
> > * See e.g. drm_helper_probe_single_connector_modes().
> > *
> > + * This function is optional.
> > + *
> > * NOTE:
> > *
> > * This only filters the mode list supplied to userspace in the
> > - * GETCONNECOTR IOCTL. Userspace is free to create modes of its own
> and
> > - * ask the kernel to use them. It this case the atomic helpers or
> legacy
> > - * CRTC helpers will not call this function. Drivers therefore must
> > - * still fully validate any mode passed in in a modeset request.
> > + * GETCONNECTOR IOCTL. Compared to
> &drm_encoder_helper_funcs.mode_valid,
> > + * &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
> > + * which are also called by the atomic helpers from
> > + * drm_atomic_helper_check_modeset(). This allows userspace to force
> and
> > + * ignore sink constraint (like the pixel clock limits in the screen's
> > + * EDID), which is useful for e.g. testing, or working around a broken
> > + * EDID. Any source hardware constraint (which always need to be
> > + * enforced) therefore should be checked in one of the above
> callbacks,
> > + * and not this one here.
> > *
> > * To avoid races with concurrent connector state updates, the helper
> > * libraries always call this with the
> &drm_mode_config.connection_mutex
>
> --
> Regards,
>
> Laurent Pinchart
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
2017-05-12 7:31 ` [PATCH] " Daniel Vetter
2017-05-12 11:29 ` Laurent Pinchart
@ 2017-05-12 12:37 ` Andrzej Hajda
2017-05-15 6:56 ` Daniel Vetter
2017-05-12 15:59 ` Jose Abreu
` (2 subsequent siblings)
4 siblings, 1 reply; 35+ messages in thread
From: Andrzej Hajda @ 2017-05-12 12:37 UTC (permalink / raw)
To: Daniel Vetter, DRI Development
Cc: Jose Abreu, Alexey Brodkin, Jose Abreu, Carlos Palminha
On 12.05.2017 09:31, Daniel Vetter wrote:
> From: Jose Abreu <Jose.Abreu@synopsys.com>
>
> This adds a new callback to crtc, encoder and bridge helper functions
> called mode_valid(). This callback shall be implemented if the
> corresponding component has some sort of restriction in the modes
> that can be displayed. A NULL callback implicates that the component
> can display all the modes.
>
> We also change the documentation so that the new and old callbacks
> are correctly documented.
>
> Only the callbacks were implemented to simplify review process,
> following patches will make use of them.
>
> Changes in v2 from Daniel:
> - Update the warning about how modes aren't filtered in atomic_check -
> the heleprs help out a lot more now.
> - Consistenly roll out that warning, crtc/encoder's atomic_check
> missed it.
> - Sprinkle more links all over the place, so it's easier to see where
> this stuff is used and how the differen hooks are related.
> - Note that ->mode_valid is optional everywhere.
> - Explain why the connector's mode_valid is special and does _not_ get
> called in atomic_check.
>
> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> Cc: Jose Abreu <joabreu@synopsys.com>
> Cc: Carlos Palminha <palminha@synopsys.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@linux.ie>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Archit Taneja <architt@codeaurora.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2)
> ---
> include/drm/drm_bridge.h | 31 +++++++++
> include/drm/drm_modeset_helper_vtables.h | 116 ++++++++++++++++++++++---------
> 2 files changed, 114 insertions(+), 33 deletions(-)
>
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index fdd82fcbf168..f694de756ecf 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -59,6 +59,31 @@ struct drm_bridge_funcs {
> void (*detach)(struct drm_bridge *bridge);
>
> /**
> + * @mode_valid:
> + *
> + * This callback is used to check if a specific mode is valid in this
> + * bridge. This should be implemented if the bridge has some sort of
> + * restriction in the modes it can display. For example, a given bridge
> + * may be responsible to set a clock value. If the clock can not
> + * produce all the values for the available modes then this callback
> + * can be used to restrict the number of modes to only the ones that
> + * can be displayed.
> + *
> + * This hook is used by the probe helpers to filter the mode list in
> + * drm_helper_probe_single_connector_modes(), and it is used by the
> + * atomic helpers to validate modes supplied by userspace in
> + * drm_atomic_helper_check_modeset().
> + *
> + * This function is optional.
> + *
> + * RETURNS:
> + *
> + * drm_mode_status Enum
> + */
> + enum drm_mode_status (*mode_valid)(struct drm_bridge *crtc,
> + const struct drm_display_mode *mode);
I have put my concerns here but it touches all mode_valid callbacks.
As the callback can be called in mode probe and atomic check it could
only inspect common set of properties for both contexts, for example
crtc cannot check to which encoder it is connected, am I right?
Maybe it would be good to emphasize it here, as it is emphasized in case
of mode_fixup callbacks.
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate and adjust a mode. The paramater
> @@ -82,6 +107,12 @@ struct drm_bridge_funcs {
> * NOT touch any persistent state (hardware or software) or data
> * structures except the passed in @state parameter.
> *
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any bridge constraints and
> + * limits checks into @mode_valid.
> + *
> * RETURNS:
> *
> * True if an acceptable configuration is possible, false if the modeset
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index c01c328f6cc8..91d071ff1232 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -106,6 +106,31 @@ struct drm_crtc_helper_funcs {
> void (*commit)(struct drm_crtc *crtc);
>
> /**
> + * @mode_valid:
> + *
> + * This callback is used to check if a specific mode is valid in this
> + * crtc. This should be implemented if the crtc has some sort of
> + * restriction in the modes it can display. For example, a given crtc
> + * may be responsible to set a clock value. If the clock can not
> + * produce all the values for the available modes then this callback
> + * can be used to restrict the number of modes to only the ones that
> + * can be displayed.
> + *
> + * This hook is used by the probe helpers to filter the mode list in
> + * drm_helper_probe_single_connector_modes(), and it is used by the
> + * atomic helpers to validate modes supplied by userspace in
> + * drm_atomic_helper_check_modeset().
> + *
> + * This function is optional.
> + *
> + * RETURNS:
> + *
> + * drm_mode_status Enum
> + */
> + enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
> + const struct drm_display_mode *mode);
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate a mode. The parameter mode is the
> @@ -132,20 +157,11 @@ struct drm_crtc_helper_funcs {
> * Atomic drivers which need to inspect and adjust more state should
> * instead use the @atomic_check callback.
> *
> - * Also beware that neither core nor helpers filter modes before
> - * passing them to the driver: While the list of modes that is
> - * advertised to userspace is filtered using the
> - * &drm_connector.mode_valid callback, neither the core nor the helpers
> - * do any filtering on modes passed in from userspace when setting a
> - * mode. It is therefore possible for userspace to pass in a mode that
> - * was previously filtered out using &drm_connector.mode_valid or add a
> - * custom mode that wasn't probed from EDID or similar to begin with.
> - * Even though this is an advanced feature and rarely used nowadays,
> - * some users rely on being able to specify modes manually so drivers
> - * must be prepared to deal with it. Specifically this means that all
> - * drivers need not only validate modes in &drm_connector.mode_valid but
> - * also in this or in the &drm_encoder_helper_funcs.mode_fixup callback
> - * to make sure invalid modes passed in from userspace are rejected.
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any CRTC constraints and
> + * limits checks into @mode_valid.
Why we do not make mode_fixup obsolete for atomic drivers as
atomic_check can do the same and is more powerful, this way we could
avoid the overlapped functionality of mode_valid and mode_fixup.
> *
> * RETURNS:
> *
> @@ -341,6 +357,12 @@ struct drm_crtc_helper_funcs {
> * state objects passed-in or assembled in the overall &drm_atomic_state
> * update tracking structure.
> *
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any CRTC constraints and
> + * limits checks into @mode_valid.
> + *
> * RETURNS:
> *
> * 0 on success, -EINVAL if the state or the transition can't be
> @@ -457,6 +479,31 @@ struct drm_encoder_helper_funcs {
> void (*dpms)(struct drm_encoder *encoder, int mode);
>
> /**
> + * @mode_valid:
> + *
> + * This callback is used to check if a specific mode is valid in this
> + * encoder. This should be implemented if the encoder has some sort
> + * of restriction in the modes it can display. For example, a given
> + * encoder may be responsible to set a clock value. If the clock can
> + * not produce all the values for the available modes then this callback
> + * can be used to restrict the number of modes to only the ones that
> + * can be displayed.
> + *
> + * This hook is used by the probe helpers to filter the mode list in
> + * drm_helper_probe_single_connector_modes(), and it is used by the
> + * atomic helpers to validate modes supplied by userspace in
> + * drm_atomic_helper_check_modeset().
> + *
> + * This function is optional.
> + *
> + * RETURNS:
> + *
> + * drm_mode_status Enum
> + */
> + enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
> + const struct drm_display_mode *mode);
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate and adjust a mode. The parameter
> @@ -482,21 +529,11 @@ struct drm_encoder_helper_funcs {
> * Atomic drivers which need to inspect and adjust more state should
> * instead use the @atomic_check callback.
> *
> - * Also beware that neither core nor helpers filter modes before
> - * passing them to the driver: While the list of modes that is
> - * advertised to userspace is filtered using the connector's
> - * &drm_connector_helper_funcs.mode_valid callback, neither the core nor
> - * the helpers do any filtering on modes passed in from userspace when
> - * setting a mode. It is therefore possible for userspace to pass in a
> - * mode that was previously filtered out using
> - * &drm_connector_helper_funcs.mode_valid or add a custom mode that
> - * wasn't probed from EDID or similar to begin with. Even though this
> - * is an advanced feature and rarely used nowadays, some users rely on
> - * being able to specify modes manually so drivers must be prepared to
> - * deal with it. Specifically this means that all drivers need not only
> - * validate modes in &drm_connector.mode_valid but also in this or in
> - * the &drm_crtc_helper_funcs.mode_fixup callback to make sure
> - * invalid modes passed in from userspace are rejected.
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any encoder constraints and
> + * limits checks into @mode_valid.
> *
> * RETURNS:
> *
> @@ -686,6 +723,12 @@ struct drm_encoder_helper_funcs {
> * state objects passed-in or assembled in the overall &drm_atomic_state
> * update tracking structure.
> *
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any encoder constraints and
> + * limits checks into @mode_valid.
> + *
> * RETURNS:
> *
> * 0 on success, -EINVAL if the state or the transition can't be
> @@ -795,13 +838,20 @@ struct drm_connector_helper_funcs {
> * (which is usually derived from the EDID data block from the sink).
> * See e.g. drm_helper_probe_single_connector_modes().
> *
> + * This function is optional.
> + *
> * NOTE:
> *
> * This only filters the mode list supplied to userspace in the
> - * GETCONNECOTR IOCTL. Userspace is free to create modes of its own and
> - * ask the kernel to use them. It this case the atomic helpers or legacy
> - * CRTC helpers will not call this function. Drivers therefore must
> - * still fully validate any mode passed in in a modeset request.
> + * GETCONNECTOR IOCTL. Compared to &drm_encoder_helper_funcs.mode_valid,
> + * &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
> + * which are also called by the atomic helpers from
> + * drm_atomic_helper_check_modeset(). This allows userspace to force and
> + * ignore sink constraint (like the pixel clock limits in the screen's
> + * EDID), which is useful for e.g. testing, or working around a broken
> + * EDID. Any source hardware constraint (which always need to be
> + * enforced) therefore should be checked in one of the above callbacks,
> + * and not this one here.
The callback has the same name but different semantic, little bit weird.
But do we really need connector::mode_valid then? I mean: are there
connectors not bound to bridge/encoder which have their own constraints?
If there are no such connectors, we can remove this callback.
If they are rare, maybe just adding loop to connector::get_modes would
be enough.
Regards
Andrzej
> *
> * To avoid races with concurrent connector state updates, the helper
> * libraries always call this with the &drm_mode_config.connection_mutex
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
2017-05-12 12:37 ` Andrzej Hajda
@ 2017-05-15 6:56 ` Daniel Vetter
2017-05-15 8:10 ` Andrzej Hajda
0 siblings, 1 reply; 35+ messages in thread
From: Daniel Vetter @ 2017-05-15 6:56 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Jose Abreu, Daniel Vetter, Alexey Brodkin, DRI Development,
Jose Abreu, Carlos Palminha
On Fri, May 12, 2017 at 02:37:17PM +0200, Andrzej Hajda wrote:
> On 12.05.2017 09:31, Daniel Vetter wrote:
> > From: Jose Abreu <Jose.Abreu@synopsys.com>
> >
> > This adds a new callback to crtc, encoder and bridge helper functions
> > called mode_valid(). This callback shall be implemented if the
> > corresponding component has some sort of restriction in the modes
> > that can be displayed. A NULL callback implicates that the component
> > can display all the modes.
> >
> > We also change the documentation so that the new and old callbacks
> > are correctly documented.
> >
> > Only the callbacks were implemented to simplify review process,
> > following patches will make use of them.
> >
> > Changes in v2 from Daniel:
> > - Update the warning about how modes aren't filtered in atomic_check -
> > the heleprs help out a lot more now.
> > - Consistenly roll out that warning, crtc/encoder's atomic_check
> > missed it.
> > - Sprinkle more links all over the place, so it's easier to see where
> > this stuff is used and how the differen hooks are related.
> > - Note that ->mode_valid is optional everywhere.
> > - Explain why the connector's mode_valid is special and does _not_ get
> > called in atomic_check.
> >
> > Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> > Cc: Jose Abreu <joabreu@synopsys.com>
> > Cc: Carlos Palminha <palminha@synopsys.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Dave Airlie <airlied@linux.ie>
> > Cc: Andrzej Hajda <a.hajda@samsung.com>
> > Cc: Archit Taneja <architt@codeaurora.org>
> > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2)
> > ---
> > include/drm/drm_bridge.h | 31 +++++++++
> > include/drm/drm_modeset_helper_vtables.h | 116 ++++++++++++++++++++++---------
> > 2 files changed, 114 insertions(+), 33 deletions(-)
> >
> > diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> > index fdd82fcbf168..f694de756ecf 100644
> > --- a/include/drm/drm_bridge.h
> > +++ b/include/drm/drm_bridge.h
> > @@ -59,6 +59,31 @@ struct drm_bridge_funcs {
> > void (*detach)(struct drm_bridge *bridge);
> >
> > /**
> > + * @mode_valid:
> > + *
> > + * This callback is used to check if a specific mode is valid in this
> > + * bridge. This should be implemented if the bridge has some sort of
> > + * restriction in the modes it can display. For example, a given bridge
> > + * may be responsible to set a clock value. If the clock can not
> > + * produce all the values for the available modes then this callback
> > + * can be used to restrict the number of modes to only the ones that
> > + * can be displayed.
> > + *
> > + * This hook is used by the probe helpers to filter the mode list in
> > + * drm_helper_probe_single_connector_modes(), and it is used by the
> > + * atomic helpers to validate modes supplied by userspace in
> > + * drm_atomic_helper_check_modeset().
> > + *
> > + * This function is optional.
> > + *
> > + * RETURNS:
> > + *
> > + * drm_mode_status Enum
> > + */
> > + enum drm_mode_status (*mode_valid)(struct drm_bridge *crtc,
> > + const struct drm_display_mode *mode);
>
> I have put my concerns here but it touches all mode_valid callbacks.
> As the callback can be called in mode probe and atomic check it could
> only inspect common set of properties for both contexts, for example
> crtc cannot check to which encoder it is connected, am I right?
> Maybe it would be good to emphasize it here, as it is emphasized in case
> of mode_fixup callbacks.
You can inspect nothing else but the mode here. Looking at anything else
is not allowed since this is the generic check which should work for any
config. Good question, so I'll augment the docs to address this.
> > +
> > + /**
> > * @mode_fixup:
> > *
> > * This callback is used to validate and adjust a mode. The paramater
> > @@ -82,6 +107,12 @@ struct drm_bridge_funcs {
> > * NOT touch any persistent state (hardware or software) or data
> > * structures except the passed in @state parameter.
> > *
> > + * Also beware that userspace can request its own custom modes, neither
> > + * core nor helpers filter modes to the list of probe modes reported by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> > + * that modes are filtered consistently put any bridge constraints and
> > + * limits checks into @mode_valid.
> > + *
> > * RETURNS:
> > *
> > * True if an acceptable configuration is possible, false if the modeset
> > diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> > index c01c328f6cc8..91d071ff1232 100644
> > --- a/include/drm/drm_modeset_helper_vtables.h
> > +++ b/include/drm/drm_modeset_helper_vtables.h
> > @@ -106,6 +106,31 @@ struct drm_crtc_helper_funcs {
> > void (*commit)(struct drm_crtc *crtc);
> >
> > /**
> > + * @mode_valid:
> > + *
> > + * This callback is used to check if a specific mode is valid in this
> > + * crtc. This should be implemented if the crtc has some sort of
> > + * restriction in the modes it can display. For example, a given crtc
> > + * may be responsible to set a clock value. If the clock can not
> > + * produce all the values for the available modes then this callback
> > + * can be used to restrict the number of modes to only the ones that
> > + * can be displayed.
> > + *
> > + * This hook is used by the probe helpers to filter the mode list in
> > + * drm_helper_probe_single_connector_modes(), and it is used by the
> > + * atomic helpers to validate modes supplied by userspace in
> > + * drm_atomic_helper_check_modeset().
> > + *
> > + * This function is optional.
> > + *
> > + * RETURNS:
> > + *
> > + * drm_mode_status Enum
> > + */
> > + enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
> > + const struct drm_display_mode *mode);
> > +
> > + /**
> > * @mode_fixup:
> > *
> > * This callback is used to validate a mode. The parameter mode is the
> > @@ -132,20 +157,11 @@ struct drm_crtc_helper_funcs {
> > * Atomic drivers which need to inspect and adjust more state should
> > * instead use the @atomic_check callback.
> > *
> > - * Also beware that neither core nor helpers filter modes before
> > - * passing them to the driver: While the list of modes that is
> > - * advertised to userspace is filtered using the
> > - * &drm_connector.mode_valid callback, neither the core nor the helpers
> > - * do any filtering on modes passed in from userspace when setting a
> > - * mode. It is therefore possible for userspace to pass in a mode that
> > - * was previously filtered out using &drm_connector.mode_valid or add a
> > - * custom mode that wasn't probed from EDID or similar to begin with.
> > - * Even though this is an advanced feature and rarely used nowadays,
> > - * some users rely on being able to specify modes manually so drivers
> > - * must be prepared to deal with it. Specifically this means that all
> > - * drivers need not only validate modes in &drm_connector.mode_valid but
> > - * also in this or in the &drm_encoder_helper_funcs.mode_fixup callback
> > - * to make sure invalid modes passed in from userspace are rejected.
> > + * Also beware that userspace can request its own custom modes, neither
> > + * core nor helpers filter modes to the list of probe modes reported by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> > + * that modes are filtered consistently put any CRTC constraints and
> > + * limits checks into @mode_valid.
>
> Why we do not make mode_fixup obsolete for atomic drivers as
> atomic_check can do the same and is more powerful, this way we could
> avoid the overlapped functionality of mode_valid and mode_fixup.
What do you mean with "make obselete"? mode_fixup is the compat callback,
atomic_check is the shiny new one, so it is already obselete.
> > *
> > * RETURNS:
> > *
> > @@ -341,6 +357,12 @@ struct drm_crtc_helper_funcs {
> > * state objects passed-in or assembled in the overall &drm_atomic_state
> > * update tracking structure.
> > *
> > + * Also beware that userspace can request its own custom modes, neither
> > + * core nor helpers filter modes to the list of probe modes reported by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> > + * that modes are filtered consistently put any CRTC constraints and
> > + * limits checks into @mode_valid.
> > + *
> > * RETURNS:
> > *
> > * 0 on success, -EINVAL if the state or the transition can't be
> > @@ -457,6 +479,31 @@ struct drm_encoder_helper_funcs {
> > void (*dpms)(struct drm_encoder *encoder, int mode);
> >
> > /**
> > + * @mode_valid:
> > + *
> > + * This callback is used to check if a specific mode is valid in this
> > + * encoder. This should be implemented if the encoder has some sort
> > + * of restriction in the modes it can display. For example, a given
> > + * encoder may be responsible to set a clock value. If the clock can
> > + * not produce all the values for the available modes then this callback
> > + * can be used to restrict the number of modes to only the ones that
> > + * can be displayed.
> > + *
> > + * This hook is used by the probe helpers to filter the mode list in
> > + * drm_helper_probe_single_connector_modes(), and it is used by the
> > + * atomic helpers to validate modes supplied by userspace in
> > + * drm_atomic_helper_check_modeset().
> > + *
> > + * This function is optional.
> > + *
> > + * RETURNS:
> > + *
> > + * drm_mode_status Enum
> > + */
> > + enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
> > + const struct drm_display_mode *mode);
> > +
> > + /**
> > * @mode_fixup:
> > *
> > * This callback is used to validate and adjust a mode. The parameter
> > @@ -482,21 +529,11 @@ struct drm_encoder_helper_funcs {
> > * Atomic drivers which need to inspect and adjust more state should
> > * instead use the @atomic_check callback.
> > *
> > - * Also beware that neither core nor helpers filter modes before
> > - * passing them to the driver: While the list of modes that is
> > - * advertised to userspace is filtered using the connector's
> > - * &drm_connector_helper_funcs.mode_valid callback, neither the core nor
> > - * the helpers do any filtering on modes passed in from userspace when
> > - * setting a mode. It is therefore possible for userspace to pass in a
> > - * mode that was previously filtered out using
> > - * &drm_connector_helper_funcs.mode_valid or add a custom mode that
> > - * wasn't probed from EDID or similar to begin with. Even though this
> > - * is an advanced feature and rarely used nowadays, some users rely on
> > - * being able to specify modes manually so drivers must be prepared to
> > - * deal with it. Specifically this means that all drivers need not only
> > - * validate modes in &drm_connector.mode_valid but also in this or in
> > - * the &drm_crtc_helper_funcs.mode_fixup callback to make sure
> > - * invalid modes passed in from userspace are rejected.
> > + * Also beware that userspace can request its own custom modes, neither
> > + * core nor helpers filter modes to the list of probe modes reported by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> > + * that modes are filtered consistently put any encoder constraints and
> > + * limits checks into @mode_valid.
> > *
> > * RETURNS:
> > *
> > @@ -686,6 +723,12 @@ struct drm_encoder_helper_funcs {
> > * state objects passed-in or assembled in the overall &drm_atomic_state
> > * update tracking structure.
> > *
> > + * Also beware that userspace can request its own custom modes, neither
> > + * core nor helpers filter modes to the list of probe modes reported by
> > + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> > + * that modes are filtered consistently put any encoder constraints and
> > + * limits checks into @mode_valid.
> > + *
> > * RETURNS:
> > *
> > * 0 on success, -EINVAL if the state or the transition can't be
> > @@ -795,13 +838,20 @@ struct drm_connector_helper_funcs {
> > * (which is usually derived from the EDID data block from the sink).
> > * See e.g. drm_helper_probe_single_connector_modes().
> > *
> > + * This function is optional.
> > + *
> > * NOTE:
> > *
> > * This only filters the mode list supplied to userspace in the
> > - * GETCONNECOTR IOCTL. Userspace is free to create modes of its own and
> > - * ask the kernel to use them. It this case the atomic helpers or legacy
> > - * CRTC helpers will not call this function. Drivers therefore must
> > - * still fully validate any mode passed in in a modeset request.
> > + * GETCONNECTOR IOCTL. Compared to &drm_encoder_helper_funcs.mode_valid,
> > + * &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
> > + * which are also called by the atomic helpers from
> > + * drm_atomic_helper_check_modeset(). This allows userspace to force and
> > + * ignore sink constraint (like the pixel clock limits in the screen's
> > + * EDID), which is useful for e.g. testing, or working around a broken
> > + * EDID. Any source hardware constraint (which always need to be
> > + * enforced) therefore should be checked in one of the above callbacks,
> > + * and not this one here.
>
> The callback has the same name but different semantic, little bit weird.
> But do we really need connector::mode_valid then? I mean: are there
> connectors not bound to bridge/encoder which have their own constraints?
> If there are no such connectors, we can remove this callback.
Yes. And the pixel clock limit is exactly the current real-world use-case:
There are hdmi screens which have a pixel clock limit set, but in reality
can take higher modes. There's users out there who want to use these
higher modes on these peculiar screens. But for everyone else (and for all
other screens), we do need to filter modes correctly (the example here is
dual-link vs. single-link limits, which is an interaction between sink and
source).
> If they are rare, maybe just adding loop to connector::get_modes would
> be enough.
What do you mean with "adding a loop"?
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
2017-05-15 6:56 ` Daniel Vetter
@ 2017-05-15 8:10 ` Andrzej Hajda
2017-05-15 8:14 ` Daniel Vetter
0 siblings, 1 reply; 35+ messages in thread
From: Andrzej Hajda @ 2017-05-15 8:10 UTC (permalink / raw)
To: Daniel Vetter
Cc: Jose Abreu, Daniel Vetter, Alexey Brodkin, DRI Development,
Jose Abreu, Carlos Palminha
On 15.05.2017 08:56, Daniel Vetter wrote:
> On Fri, May 12, 2017 at 02:37:17PM +0200, Andrzej Hajda wrote:
>> On 12.05.2017 09:31, Daniel Vetter wrote:
>>> From: Jose Abreu <Jose.Abreu@synopsys.com>
>>>
>>> This adds a new callback to crtc, encoder and bridge helper functions
>>> called mode_valid(). This callback shall be implemented if the
>>> corresponding component has some sort of restriction in the modes
>>> that can be displayed. A NULL callback implicates that the component
>>> can display all the modes.
>>>
>>> We also change the documentation so that the new and old callbacks
>>> are correctly documented.
>>>
>>> Only the callbacks were implemented to simplify review process,
>>> following patches will make use of them.
>>>
>>> Changes in v2 from Daniel:
>>> - Update the warning about how modes aren't filtered in atomic_check -
>>> the heleprs help out a lot more now.
>>> - Consistenly roll out that warning, crtc/encoder's atomic_check
>>> missed it.
>>> - Sprinkle more links all over the place, so it's easier to see where
>>> this stuff is used and how the differen hooks are related.
>>> - Note that ->mode_valid is optional everywhere.
>>> - Explain why the connector's mode_valid is special and does _not_ get
>>> called in atomic_check.
>>>
>>> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
>>> Cc: Jose Abreu <joabreu@synopsys.com>
>>> Cc: Carlos Palminha <palminha@synopsys.com>
>>> Cc: Alexey Brodkin <abrodkin@synopsys.com>
>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>> Cc: Dave Airlie <airlied@linux.ie>
>>> Cc: Andrzej Hajda <a.hajda@samsung.com>
>>> Cc: Archit Taneja <architt@codeaurora.org>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2)
>>> ---
>>> include/drm/drm_bridge.h | 31 +++++++++
>>> include/drm/drm_modeset_helper_vtables.h | 116 ++++++++++++++++++++++---------
>>> 2 files changed, 114 insertions(+), 33 deletions(-)
>>>
>>> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
>>> index fdd82fcbf168..f694de756ecf 100644
>>> --- a/include/drm/drm_bridge.h
>>> +++ b/include/drm/drm_bridge.h
>>> @@ -59,6 +59,31 @@ struct drm_bridge_funcs {
>>> void (*detach)(struct drm_bridge *bridge);
>>>
>>> /**
>>> + * @mode_valid:
>>> + *
>>> + * This callback is used to check if a specific mode is valid in this
>>> + * bridge. This should be implemented if the bridge has some sort of
>>> + * restriction in the modes it can display. For example, a given bridge
>>> + * may be responsible to set a clock value. If the clock can not
>>> + * produce all the values for the available modes then this callback
>>> + * can be used to restrict the number of modes to only the ones that
>>> + * can be displayed.
>>> + *
>>> + * This hook is used by the probe helpers to filter the mode list in
>>> + * drm_helper_probe_single_connector_modes(), and it is used by the
>>> + * atomic helpers to validate modes supplied by userspace in
>>> + * drm_atomic_helper_check_modeset().
>>> + *
>>> + * This function is optional.
>>> + *
>>> + * RETURNS:
>>> + *
>>> + * drm_mode_status Enum
>>> + */
>>> + enum drm_mode_status (*mode_valid)(struct drm_bridge *crtc,
>>> + const struct drm_display_mode *mode);
>> I have put my concerns here but it touches all mode_valid callbacks.
>> As the callback can be called in mode probe and atomic check it could
>> only inspect common set of properties for both contexts, for example
>> crtc cannot check to which encoder it is connected, am I right?
>> Maybe it would be good to emphasize it here, as it is emphasized in case
>> of mode_fixup callbacks.
> You can inspect nothing else but the mode here. Looking at anything else
> is not allowed since this is the generic check which should work for any
> config. Good question, so I'll augment the docs to address this.
>
>>> +
>>> + /**
>>> * @mode_fixup:
>>> *
>>> * This callback is used to validate and adjust a mode. The paramater
>>> @@ -82,6 +107,12 @@ struct drm_bridge_funcs {
>>> * NOT touch any persistent state (hardware or software) or data
>>> * structures except the passed in @state parameter.
>>> *
>>> + * Also beware that userspace can request its own custom modes, neither
>>> + * core nor helpers filter modes to the list of probe modes reported by
>>> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
>>> + * that modes are filtered consistently put any bridge constraints and
>>> + * limits checks into @mode_valid.
>>> + *
>>> * RETURNS:
>>> *
>>> * True if an acceptable configuration is possible, false if the modeset
>>> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
>>> index c01c328f6cc8..91d071ff1232 100644
>>> --- a/include/drm/drm_modeset_helper_vtables.h
>>> +++ b/include/drm/drm_modeset_helper_vtables.h
>>> @@ -106,6 +106,31 @@ struct drm_crtc_helper_funcs {
>>> void (*commit)(struct drm_crtc *crtc);
>>>
>>> /**
>>> + * @mode_valid:
>>> + *
>>> + * This callback is used to check if a specific mode is valid in this
>>> + * crtc. This should be implemented if the crtc has some sort of
>>> + * restriction in the modes it can display. For example, a given crtc
>>> + * may be responsible to set a clock value. If the clock can not
>>> + * produce all the values for the available modes then this callback
>>> + * can be used to restrict the number of modes to only the ones that
>>> + * can be displayed.
>>> + *
>>> + * This hook is used by the probe helpers to filter the mode list in
>>> + * drm_helper_probe_single_connector_modes(), and it is used by the
>>> + * atomic helpers to validate modes supplied by userspace in
>>> + * drm_atomic_helper_check_modeset().
>>> + *
>>> + * This function is optional.
>>> + *
>>> + * RETURNS:
>>> + *
>>> + * drm_mode_status Enum
>>> + */
>>> + enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
>>> + const struct drm_display_mode *mode);
>>> +
>>> + /**
>>> * @mode_fixup:
>>> *
>>> * This callback is used to validate a mode. The parameter mode is the
>>> @@ -132,20 +157,11 @@ struct drm_crtc_helper_funcs {
>>> * Atomic drivers which need to inspect and adjust more state should
>>> * instead use the @atomic_check callback.
>>> *
>>> - * Also beware that neither core nor helpers filter modes before
>>> - * passing them to the driver: While the list of modes that is
>>> - * advertised to userspace is filtered using the
>>> - * &drm_connector.mode_valid callback, neither the core nor the helpers
>>> - * do any filtering on modes passed in from userspace when setting a
>>> - * mode. It is therefore possible for userspace to pass in a mode that
>>> - * was previously filtered out using &drm_connector.mode_valid or add a
>>> - * custom mode that wasn't probed from EDID or similar to begin with.
>>> - * Even though this is an advanced feature and rarely used nowadays,
>>> - * some users rely on being able to specify modes manually so drivers
>>> - * must be prepared to deal with it. Specifically this means that all
>>> - * drivers need not only validate modes in &drm_connector.mode_valid but
>>> - * also in this or in the &drm_encoder_helper_funcs.mode_fixup callback
>>> - * to make sure invalid modes passed in from userspace are rejected.
>>> + * Also beware that userspace can request its own custom modes, neither
>>> + * core nor helpers filter modes to the list of probe modes reported by
>>> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
>>> + * that modes are filtered consistently put any CRTC constraints and
>>> + * limits checks into @mode_valid.
>> Why we do not make mode_fixup obsolete for atomic drivers as
>> atomic_check can do the same and is more powerful, this way we could
>> avoid the overlapped functionality of mode_valid and mode_fixup.
> What do you mean with "make obselete"? mode_fixup is the compat callback,
> atomic_check is the shiny new one, so it is already obselete.
Hmm, the docs says 'atomic drivers which need to inspect and adjust more
state should instead use the @atomic_check callback', it does not sound
like 'mode_fixup is obsolete for atomic drivers, please use atomic_check
instead' :)
>>> *
>>> * RETURNS:
>>> *
>>> @@ -341,6 +357,12 @@ struct drm_crtc_helper_funcs {
>>> * state objects passed-in or assembled in the overall &drm_atomic_state
>>> * update tracking structure.
>>> *
>>> + * Also beware that userspace can request its own custom modes, neither
>>> + * core nor helpers filter modes to the list of probe modes reported by
>>> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
>>> + * that modes are filtered consistently put any CRTC constraints and
>>> + * limits checks into @mode_valid.
>>> + *
>>> * RETURNS:
>>> *
>>> * 0 on success, -EINVAL if the state or the transition can't be
>>> @@ -457,6 +479,31 @@ struct drm_encoder_helper_funcs {
>>> void (*dpms)(struct drm_encoder *encoder, int mode);
>>>
>>> /**
>>> + * @mode_valid:
>>> + *
>>> + * This callback is used to check if a specific mode is valid in this
>>> + * encoder. This should be implemented if the encoder has some sort
>>> + * of restriction in the modes it can display. For example, a given
>>> + * encoder may be responsible to set a clock value. If the clock can
>>> + * not produce all the values for the available modes then this callback
>>> + * can be used to restrict the number of modes to only the ones that
>>> + * can be displayed.
>>> + *
>>> + * This hook is used by the probe helpers to filter the mode list in
>>> + * drm_helper_probe_single_connector_modes(), and it is used by the
>>> + * atomic helpers to validate modes supplied by userspace in
>>> + * drm_atomic_helper_check_modeset().
>>> + *
>>> + * This function is optional.
>>> + *
>>> + * RETURNS:
>>> + *
>>> + * drm_mode_status Enum
>>> + */
>>> + enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
>>> + const struct drm_display_mode *mode);
>>> +
>>> + /**
>>> * @mode_fixup:
>>> *
>>> * This callback is used to validate and adjust a mode. The parameter
>>> @@ -482,21 +529,11 @@ struct drm_encoder_helper_funcs {
>>> * Atomic drivers which need to inspect and adjust more state should
>>> * instead use the @atomic_check callback.
>>> *
>>> - * Also beware that neither core nor helpers filter modes before
>>> - * passing them to the driver: While the list of modes that is
>>> - * advertised to userspace is filtered using the connector's
>>> - * &drm_connector_helper_funcs.mode_valid callback, neither the core nor
>>> - * the helpers do any filtering on modes passed in from userspace when
>>> - * setting a mode. It is therefore possible for userspace to pass in a
>>> - * mode that was previously filtered out using
>>> - * &drm_connector_helper_funcs.mode_valid or add a custom mode that
>>> - * wasn't probed from EDID or similar to begin with. Even though this
>>> - * is an advanced feature and rarely used nowadays, some users rely on
>>> - * being able to specify modes manually so drivers must be prepared to
>>> - * deal with it. Specifically this means that all drivers need not only
>>> - * validate modes in &drm_connector.mode_valid but also in this or in
>>> - * the &drm_crtc_helper_funcs.mode_fixup callback to make sure
>>> - * invalid modes passed in from userspace are rejected.
>>> + * Also beware that userspace can request its own custom modes, neither
>>> + * core nor helpers filter modes to the list of probe modes reported by
>>> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
>>> + * that modes are filtered consistently put any encoder constraints and
>>> + * limits checks into @mode_valid.
>>> *
>>> * RETURNS:
>>> *
>>> @@ -686,6 +723,12 @@ struct drm_encoder_helper_funcs {
>>> * state objects passed-in or assembled in the overall &drm_atomic_state
>>> * update tracking structure.
>>> *
>>> + * Also beware that userspace can request its own custom modes, neither
>>> + * core nor helpers filter modes to the list of probe modes reported by
>>> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
>>> + * that modes are filtered consistently put any encoder constraints and
>>> + * limits checks into @mode_valid.
>>> + *
>>> * RETURNS:
>>> *
>>> * 0 on success, -EINVAL if the state or the transition can't be
>>> @@ -795,13 +838,20 @@ struct drm_connector_helper_funcs {
>>> * (which is usually derived from the EDID data block from the sink).
>>> * See e.g. drm_helper_probe_single_connector_modes().
>>> *
>>> + * This function is optional.
>>> + *
>>> * NOTE:
>>> *
>>> * This only filters the mode list supplied to userspace in the
>>> - * GETCONNECOTR IOCTL. Userspace is free to create modes of its own and
>>> - * ask the kernel to use them. It this case the atomic helpers or legacy
>>> - * CRTC helpers will not call this function. Drivers therefore must
>>> - * still fully validate any mode passed in in a modeset request.
>>> + * GETCONNECTOR IOCTL. Compared to &drm_encoder_helper_funcs.mode_valid,
>>> + * &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
>>> + * which are also called by the atomic helpers from
>>> + * drm_atomic_helper_check_modeset(). This allows userspace to force and
>>> + * ignore sink constraint (like the pixel clock limits in the screen's
>>> + * EDID), which is useful for e.g. testing, or working around a broken
>>> + * EDID. Any source hardware constraint (which always need to be
>>> + * enforced) therefore should be checked in one of the above callbacks,
>>> + * and not this one here.
>> The callback has the same name but different semantic, little bit weird.
>> But do we really need connector::mode_valid then? I mean: are there
>> connectors not bound to bridge/encoder which have their own constraints?
>> If there are no such connectors, we can remove this callback.
> Yes. And the pixel clock limit is exactly the current real-world use-case:
> There are hdmi screens which have a pixel clock limit set, but in reality
> can take higher modes. There's users out there who want to use these
> higher modes on these peculiar screens. But for everyone else (and for all
> other screens), we do need to filter modes correctly (the example here is
> dual-link vs. single-link limits, which is an interaction between sink and
> source).
>
>> If they are rare, maybe just adding loop to connector::get_modes would
>> be enough.
> What do you mean with "adding a loop"?
> -Daniel
Sorry for confusing shortcut, I have just inspected call sites of both
callbacks - drm_helper_probe_single_connector_modes, both callbacks are
called from this function, so my idea was to move loop
'list_for_each_entry(mode, &connector->modes, head){ ....,
...->mode_valid(...); ....}' from
drm_helper_probe_single_connector_modes to .get_modes callback. After
looking bit more at this function I have realized that such change is
not so obvious, and it is not really clear if the final result will be
better :).
Regards
Andrzej
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
2017-05-15 8:10 ` Andrzej Hajda
@ 2017-05-15 8:14 ` Daniel Vetter
0 siblings, 0 replies; 35+ messages in thread
From: Daniel Vetter @ 2017-05-15 8:14 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Jose Abreu, Alexey Brodkin, DRI Development, Jose Abreu,
Carlos Palminha
On Mon, May 15, 2017 at 10:10 AM, Andrzej Hajda <a.hajda@samsung.com> wrote:
> Sorry for confusing shortcut, I have just inspected call sites of both
> callbacks - drm_helper_probe_single_connector_modes, both callbacks are
> called from this function, so my idea was to move loop
> 'list_for_each_entry(mode, &connector->modes, head){ ....,
> ...->mode_valid(...); ....}' from
> drm_helper_probe_single_connector_modes to .get_modes callback. After
> looking bit more at this function I have realized that such change is
> not so obvious, and it is not really clear if the final result will be
> better :).
This would defeat the purpose of ->get_modes, which is to just grab
the modes from the sink, without filtering for source constraints,
which is done by ->mode_valid. That framework is why we have the probe
helpers, if you want to do something else you can always implement
->fill_modes (which is the uapi entry point) yourself.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
2017-05-12 7:31 ` [PATCH] " Daniel Vetter
2017-05-12 11:29 ` Laurent Pinchart
2017-05-12 12:37 ` Andrzej Hajda
@ 2017-05-12 15:59 ` Jose Abreu
2017-05-15 9:11 ` [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better Daniel Vetter
2017-05-15 9:33 ` [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks Daniel Vetter
4 siblings, 0 replies; 35+ messages in thread
From: Jose Abreu @ 2017-05-12 15:59 UTC (permalink / raw)
To: Daniel Vetter, DRI Development
Cc: Jose Abreu, Alexey Brodkin, Carlos Palminha
Hi Daniel,
On 12-05-2017 08:31, Daniel Vetter wrote:
> From: Jose Abreu <Jose.Abreu@synopsys.com>
>
> This adds a new callback to crtc, encoder and bridge helper functions
> called mode_valid(). This callback shall be implemented if the
> corresponding component has some sort of restriction in the modes
> that can be displayed. A NULL callback implicates that the component
> can display all the modes.
>
> We also change the documentation so that the new and old callbacks
> are correctly documented.
>
> Only the callbacks were implemented to simplify review process,
> following patches will make use of them.
>
> Changes in v2 from Daniel:
> - Update the warning about how modes aren't filtered in atomic_check -
> the heleprs help out a lot more now.
> - Consistenly roll out that warning, crtc/encoder's atomic_check
> missed it.
> - Sprinkle more links all over the place, so it's easier to see where
> this stuff is used and how the differen hooks are related.
> - Note that ->mode_valid is optional everywhere.
> - Explain why the connector's mode_valid is special and does _not_ get
> called in atomic_check.
>
> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> Cc: Jose Abreu <joabreu@synopsys.com>
> Cc: Carlos Palminha <palminha@synopsys.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@linux.ie>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Archit Taneja <architt@codeaurora.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2)
Thanks! Looks fine by me.
Reviewed-by: Jose Abreu <joabreu@synopsys.com>
Best regards,
Jose Miguel Abreu
> ---
> include/drm/drm_bridge.h | 31 +++++++++
> include/drm/drm_modeset_helper_vtables.h | 116 ++++++++++++++++++++++---------
> 2 files changed, 114 insertions(+), 33 deletions(-)
>
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index fdd82fcbf168..f694de756ecf 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -59,6 +59,31 @@ struct drm_bridge_funcs {
> void (*detach)(struct drm_bridge *bridge);
>
> /**
> + * @mode_valid:
> + *
> + * This callback is used to check if a specific mode is valid in this
> + * bridge. This should be implemented if the bridge has some sort of
> + * restriction in the modes it can display. For example, a given bridge
> + * may be responsible to set a clock value. If the clock can not
> + * produce all the values for the available modes then this callback
> + * can be used to restrict the number of modes to only the ones that
> + * can be displayed.
> + *
> + * This hook is used by the probe helpers to filter the mode list in
> + * drm_helper_probe_single_connector_modes(), and it is used by the
> + * atomic helpers to validate modes supplied by userspace in
> + * drm_atomic_helper_check_modeset().
> + *
> + * This function is optional.
> + *
> + * RETURNS:
> + *
> + * drm_mode_status Enum
> + */
> + enum drm_mode_status (*mode_valid)(struct drm_bridge *crtc,
> + const struct drm_display_mode *mode);
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate and adjust a mode. The paramater
> @@ -82,6 +107,12 @@ struct drm_bridge_funcs {
> * NOT touch any persistent state (hardware or software) or data
> * structures except the passed in @state parameter.
> *
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any bridge constraints and
> + * limits checks into @mode_valid.
> + *
> * RETURNS:
> *
> * True if an acceptable configuration is possible, false if the modeset
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index c01c328f6cc8..91d071ff1232 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -106,6 +106,31 @@ struct drm_crtc_helper_funcs {
> void (*commit)(struct drm_crtc *crtc);
>
> /**
> + * @mode_valid:
> + *
> + * This callback is used to check if a specific mode is valid in this
> + * crtc. This should be implemented if the crtc has some sort of
> + * restriction in the modes it can display. For example, a given crtc
> + * may be responsible to set a clock value. If the clock can not
> + * produce all the values for the available modes then this callback
> + * can be used to restrict the number of modes to only the ones that
> + * can be displayed.
> + *
> + * This hook is used by the probe helpers to filter the mode list in
> + * drm_helper_probe_single_connector_modes(), and it is used by the
> + * atomic helpers to validate modes supplied by userspace in
> + * drm_atomic_helper_check_modeset().
> + *
> + * This function is optional.
> + *
> + * RETURNS:
> + *
> + * drm_mode_status Enum
> + */
> + enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
> + const struct drm_display_mode *mode);
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate a mode. The parameter mode is the
> @@ -132,20 +157,11 @@ struct drm_crtc_helper_funcs {
> * Atomic drivers which need to inspect and adjust more state should
> * instead use the @atomic_check callback.
> *
> - * Also beware that neither core nor helpers filter modes before
> - * passing them to the driver: While the list of modes that is
> - * advertised to userspace is filtered using the
> - * &drm_connector.mode_valid callback, neither the core nor the helpers
> - * do any filtering on modes passed in from userspace when setting a
> - * mode. It is therefore possible for userspace to pass in a mode that
> - * was previously filtered out using &drm_connector.mode_valid or add a
> - * custom mode that wasn't probed from EDID or similar to begin with.
> - * Even though this is an advanced feature and rarely used nowadays,
> - * some users rely on being able to specify modes manually so drivers
> - * must be prepared to deal with it. Specifically this means that all
> - * drivers need not only validate modes in &drm_connector.mode_valid but
> - * also in this or in the &drm_encoder_helper_funcs.mode_fixup callback
> - * to make sure invalid modes passed in from userspace are rejected.
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any CRTC constraints and
> + * limits checks into @mode_valid.
> *
> * RETURNS:
> *
> @@ -341,6 +357,12 @@ struct drm_crtc_helper_funcs {
> * state objects passed-in or assembled in the overall &drm_atomic_state
> * update tracking structure.
> *
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any CRTC constraints and
> + * limits checks into @mode_valid.
> + *
> * RETURNS:
> *
> * 0 on success, -EINVAL if the state or the transition can't be
> @@ -457,6 +479,31 @@ struct drm_encoder_helper_funcs {
> void (*dpms)(struct drm_encoder *encoder, int mode);
>
> /**
> + * @mode_valid:
> + *
> + * This callback is used to check if a specific mode is valid in this
> + * encoder. This should be implemented if the encoder has some sort
> + * of restriction in the modes it can display. For example, a given
> + * encoder may be responsible to set a clock value. If the clock can
> + * not produce all the values for the available modes then this callback
> + * can be used to restrict the number of modes to only the ones that
> + * can be displayed.
> + *
> + * This hook is used by the probe helpers to filter the mode list in
> + * drm_helper_probe_single_connector_modes(), and it is used by the
> + * atomic helpers to validate modes supplied by userspace in
> + * drm_atomic_helper_check_modeset().
> + *
> + * This function is optional.
> + *
> + * RETURNS:
> + *
> + * drm_mode_status Enum
> + */
> + enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
> + const struct drm_display_mode *mode);
> +
> + /**
> * @mode_fixup:
> *
> * This callback is used to validate and adjust a mode. The parameter
> @@ -482,21 +529,11 @@ struct drm_encoder_helper_funcs {
> * Atomic drivers which need to inspect and adjust more state should
> * instead use the @atomic_check callback.
> *
> - * Also beware that neither core nor helpers filter modes before
> - * passing them to the driver: While the list of modes that is
> - * advertised to userspace is filtered using the connector's
> - * &drm_connector_helper_funcs.mode_valid callback, neither the core nor
> - * the helpers do any filtering on modes passed in from userspace when
> - * setting a mode. It is therefore possible for userspace to pass in a
> - * mode that was previously filtered out using
> - * &drm_connector_helper_funcs.mode_valid or add a custom mode that
> - * wasn't probed from EDID or similar to begin with. Even though this
> - * is an advanced feature and rarely used nowadays, some users rely on
> - * being able to specify modes manually so drivers must be prepared to
> - * deal with it. Specifically this means that all drivers need not only
> - * validate modes in &drm_connector.mode_valid but also in this or in
> - * the &drm_crtc_helper_funcs.mode_fixup callback to make sure
> - * invalid modes passed in from userspace are rejected.
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any encoder constraints and
> + * limits checks into @mode_valid.
> *
> * RETURNS:
> *
> @@ -686,6 +723,12 @@ struct drm_encoder_helper_funcs {
> * state objects passed-in or assembled in the overall &drm_atomic_state
> * update tracking structure.
> *
> + * Also beware that userspace can request its own custom modes, neither
> + * core nor helpers filter modes to the list of probe modes reported by
> + * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
> + * that modes are filtered consistently put any encoder constraints and
> + * limits checks into @mode_valid.
> + *
> * RETURNS:
> *
> * 0 on success, -EINVAL if the state or the transition can't be
> @@ -795,13 +838,20 @@ struct drm_connector_helper_funcs {
> * (which is usually derived from the EDID data block from the sink).
> * See e.g. drm_helper_probe_single_connector_modes().
> *
> + * This function is optional.
> + *
> * NOTE:
> *
> * This only filters the mode list supplied to userspace in the
> - * GETCONNECOTR IOCTL. Userspace is free to create modes of its own and
> - * ask the kernel to use them. It this case the atomic helpers or legacy
> - * CRTC helpers will not call this function. Drivers therefore must
> - * still fully validate any mode passed in in a modeset request.
> + * GETCONNECTOR IOCTL. Compared to &drm_encoder_helper_funcs.mode_valid,
> + * &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
> + * which are also called by the atomic helpers from
> + * drm_atomic_helper_check_modeset(). This allows userspace to force and
> + * ignore sink constraint (like the pixel clock limits in the screen's
> + * EDID), which is useful for e.g. testing, or working around a broken
> + * EDID. Any source hardware constraint (which always need to be
> + * enforced) therefore should be checked in one of the above callbacks,
> + * and not this one here.
> *
> * To avoid races with concurrent connector state updates, the helper
> * libraries always call this with the &drm_mode_config.connection_mutex
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread* [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better
2017-05-12 7:31 ` [PATCH] " Daniel Vetter
` (2 preceding siblings ...)
2017-05-12 15:59 ` Jose Abreu
@ 2017-05-15 9:11 ` Daniel Vetter
2017-05-15 9:11 ` [PATCH 2/2] drm/doc: Clarify mode_fixup vs. atomic_check a bit more Daniel Vetter
` (2 more replies)
2017-05-15 9:33 ` [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks Daniel Vetter
4 siblings, 3 replies; 35+ messages in thread
From: Daniel Vetter @ 2017-05-15 9:11 UTC (permalink / raw)
To: DRI Development
Cc: Jose Abreu, Daniel Vetter, Laurent Pinchart, Daniel Vetter
Laurent started a massive discussion on IRC about this. Let's try to
document common usage a bit better.
v2: Cross-links+typos.
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
include/drm/drm_bridge.h | 2 +-
include/drm/drm_crtc.h | 28 +++++++++++++++++++++++++---
include/drm/drm_modeset_helper_vtables.h | 6 ++++--
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index f694de756ecf..f3ad38d0d621 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -91,7 +91,7 @@ struct drm_bridge_funcs {
* the display chain, either the final &drm_connector or the next
* &drm_bridge. The parameter adjusted_mode is the input mode the bridge
* requires. It can be modified by this callback and does not need to
- * match mode.
+ * match mode. See also &drm_crtc_state.adjusted_mode for more details.
*
* This is the only hook that allows a bridge to reject a modeset. If
* this function passes all other callbacks must succeed for this
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 06236b002c22..5f5d53973ca5 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -90,8 +90,6 @@ struct drm_plane_helper_funcs;
* @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
* @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
* @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
- * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
- * @mode: current mode timings
* @mode_blob: &drm_property_blob for @mode
* @state: backpointer to global drm_atomic_state
*
@@ -131,9 +129,33 @@ struct drm_crtc_state {
u32 connector_mask;
u32 encoder_mask;
- /* adjusted_mode: for use by helpers and drivers */
+ /**
+ * @adjusted_mode:
+ *
+ * Internal display timings which can be used by the driver to handle
+ * differences between the mode requested by userspace in @mode and what
+ * is actually programmed into the hardware. It is purely driver
+ * implementation defined what exactly this adjusted mode means. Usually
+ * it is used to store the hardware display timings used between the
+ * CRTC and encoder blocks.
+ */
struct drm_display_mode adjusted_mode;
+ /**
+ * @mode:
+ *
+ * Display timings requested by userspace. The driver should try to
+ * match the refresh rate as close as possible (but note that it's
+ * undefined what exactly is close enough, e.g. some of the HDMI modes
+ * only differ in less than 1% of the refresh rate). The active width
+ * and height as observed by userspace for positioning planes must match
+ * exactly.
+ *
+ * For external connectors where the sink isn't fixed (like with a
+ * built-in panel), this mode here should match the physical mode on the
+ * wire to the last details (i.e. including sync polarities and
+ * everything).
+ */
struct drm_display_mode mode;
/* blob property to expose current mode to atomic userspace */
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index 91d071ff1232..c72fca544a41 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -138,7 +138,8 @@ struct drm_crtc_helper_funcs {
* encoders need to be fed with. Note that this is the inverse semantics
* of the meaning for the &drm_encoder and &drm_bridge_funcs.mode_fixup
* vfunc. If the CRTC cannot support the requested conversion from mode
- * to adjusted_mode it should reject the modeset.
+ * to adjusted_mode it should reject the modeset. See also
+ * &drm_crtc_state.adjusted_mode for more details.
*
* This function is used by both legacy CRTC helpers and atomic helpers.
* With atomic helpers it is optional.
@@ -510,7 +511,8 @@ struct drm_encoder_helper_funcs {
* mode is the display mode that should be fed to the next element in
* the display chain, either the final &drm_connector or a &drm_bridge.
* The parameter adjusted_mode is the input mode the encoder requires. It
- * can be modified by this callback and does not need to match mode.
+ * can be modified by this callback and does not need to match mode. See
+ * also &drm_crtc_state.adjusted_mode for more details.
*
* This function is used by both legacy CRTC helpers and atomic helpers.
* This hook is optional.
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 35+ messages in thread* [PATCH 2/2] drm/doc: Clarify mode_fixup vs. atomic_check a bit more
2017-05-15 9:11 ` [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better Daniel Vetter
@ 2017-05-15 9:11 ` Daniel Vetter
2017-05-16 2:41 ` Jose Abreu
2017-05-16 13:14 ` Andrzej Hajda
2017-05-16 2:38 ` [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better Jose Abreu
2017-05-16 13:17 ` Andrzej Hajda
2 siblings, 2 replies; 35+ messages in thread
From: Daniel Vetter @ 2017-05-15 9:11 UTC (permalink / raw)
To: DRI Development
Cc: Jose Abreu, Daniel Vetter, Laurent Pinchart, Daniel Vetter
Brought up by both Laurent and Andrzej when reviewing the new
->mode_valid hooks. Since mode_fixup is just a simpler version of the
much more generic atomic_check we can't really unify it with
mode_valid. Most drivers should probably switch their current
mode_fixup code to either the new mode_valid or the atomic_check
hooks, but e.g. that doesn't exist yet for bridges, and for CRTCs the
situation is a bit more complicated. Hence there's no clear
equivalence between mode_fixup and mode_valid, even if it looks like
that at first glance.
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
include/drm/drm_modeset_helper_vtables.h | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index c72fca544a41..613b2a602b77 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -156,7 +156,11 @@ struct drm_crtc_helper_funcs {
* allowed.
*
* Atomic drivers which need to inspect and adjust more state should
- * instead use the @atomic_check callback.
+ * instead use the @atomic_check callback, but note that they're not
+ * perfectly equivalent: @mode_valid is called from
+ * drm_atomic_helper_check_modeset(), but @atomic_check is called from
+ * drm_atomic_helper_check_planes(), because originally it was meant for
+ * plane update checks only..
*
* Also beware that userspace can request its own custom modes, neither
* core nor helpers filter modes to the list of probe modes reported by
@@ -529,7 +533,9 @@ struct drm_encoder_helper_funcs {
* allowed.
*
* Atomic drivers which need to inspect and adjust more state should
- * instead use the @atomic_check callback.
+ * instead use the @atomic_check callback. If @atomic_check is used,
+ * this hook isn't called since @atomic_check allows a strict superset
+ * of the functionality of @mode_fixup.
*
* Also beware that userspace can request its own custom modes, neither
* core nor helpers filter modes to the list of probe modes reported by
@@ -716,6 +722,11 @@ struct drm_encoder_helper_funcs {
* update the CRTC to match what the encoder needs for the requested
* connector.
*
+ * Since this provides a strict superset of the functionality of
+ * @mode_fixup (the requested and adjusted modes are both available
+ * through the passed in &struct drm_crtc_state) @mode_fixup is not
+ * called when @atomic_check is implemented.
+ *
* This function is used by the atomic helpers, but it is optional.
*
* NOTE:
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 35+ messages in thread* Re: [PATCH 2/2] drm/doc: Clarify mode_fixup vs. atomic_check a bit more
2017-05-15 9:11 ` [PATCH 2/2] drm/doc: Clarify mode_fixup vs. atomic_check a bit more Daniel Vetter
@ 2017-05-16 2:41 ` Jose Abreu
2017-05-16 13:14 ` Andrzej Hajda
1 sibling, 0 replies; 35+ messages in thread
From: Jose Abreu @ 2017-05-16 2:41 UTC (permalink / raw)
To: Daniel Vetter, DRI Development
Cc: Jose Abreu, Laurent Pinchart, Daniel Vetter
Hi Daniel,
On 15-05-2017 10:11, Daniel Vetter wrote:
> Brought up by both Laurent and Andrzej when reviewing the new
> ->mode_valid hooks. Since mode_fixup is just a simpler version of the
> much more generic atomic_check we can't really unify it with
> mode_valid. Most drivers should probably switch their current
> mode_fixup code to either the new mode_valid or the atomic_check
> hooks, but e.g. that doesn't exist yet for bridges, and for CRTCs the
> situation is a bit more complicated. Hence there's no clear
> equivalence between mode_fixup and mode_valid, even if it looks like
> that at first glance.
>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Reviewed-by: Jose Abreu <joabreu@synopsys.com>
Best regards,
Jose Miguel Abreu
> ---
> include/drm/drm_modeset_helper_vtables.h | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index c72fca544a41..613b2a602b77 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -156,7 +156,11 @@ struct drm_crtc_helper_funcs {
> * allowed.
> *
> * Atomic drivers which need to inspect and adjust more state should
> - * instead use the @atomic_check callback.
> + * instead use the @atomic_check callback, but note that they're not
> + * perfectly equivalent: @mode_valid is called from
> + * drm_atomic_helper_check_modeset(), but @atomic_check is called from
> + * drm_atomic_helper_check_planes(), because originally it was meant for
> + * plane update checks only..
> *
> * Also beware that userspace can request its own custom modes, neither
> * core nor helpers filter modes to the list of probe modes reported by
> @@ -529,7 +533,9 @@ struct drm_encoder_helper_funcs {
> * allowed.
> *
> * Atomic drivers which need to inspect and adjust more state should
> - * instead use the @atomic_check callback.
> + * instead use the @atomic_check callback. If @atomic_check is used,
> + * this hook isn't called since @atomic_check allows a strict superset
> + * of the functionality of @mode_fixup.
> *
> * Also beware that userspace can request its own custom modes, neither
> * core nor helpers filter modes to the list of probe modes reported by
> @@ -716,6 +722,11 @@ struct drm_encoder_helper_funcs {
> * update the CRTC to match what the encoder needs for the requested
> * connector.
> *
> + * Since this provides a strict superset of the functionality of
> + * @mode_fixup (the requested and adjusted modes are both available
> + * through the passed in &struct drm_crtc_state) @mode_fixup is not
> + * called when @atomic_check is implemented.
> + *
> * This function is used by the atomic helpers, but it is optional.
> *
> * NOTE:
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH 2/2] drm/doc: Clarify mode_fixup vs. atomic_check a bit more
2017-05-15 9:11 ` [PATCH 2/2] drm/doc: Clarify mode_fixup vs. atomic_check a bit more Daniel Vetter
2017-05-16 2:41 ` Jose Abreu
@ 2017-05-16 13:14 ` Andrzej Hajda
1 sibling, 0 replies; 35+ messages in thread
From: Andrzej Hajda @ 2017-05-16 13:14 UTC (permalink / raw)
To: Daniel Vetter, DRI Development
Cc: Jose Abreu, Daniel Vetter, Laurent Pinchart
On 15.05.2017 11:11, Daniel Vetter wrote:
> Brought up by both Laurent and Andrzej when reviewing the new
> ->mode_valid hooks. Since mode_fixup is just a simpler version of the
> much more generic atomic_check we can't really unify it with
> mode_valid. Most drivers should probably switch their current
> mode_fixup code to either the new mode_valid or the atomic_check
> hooks, but e.g. that doesn't exist yet for bridges, and for CRTCs the
> situation is a bit more complicated. Hence there's no clear
> equivalence between mode_fixup and mode_valid, even if it looks like
> that at first glance.
>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
> include/drm/drm_modeset_helper_vtables.h | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index c72fca544a41..613b2a602b77 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -156,7 +156,11 @@ struct drm_crtc_helper_funcs {
> * allowed.
> *
> * Atomic drivers which need to inspect and adjust more state should
> - * instead use the @atomic_check callback.
> + * instead use the @atomic_check callback, but note that they're not
> + * perfectly equivalent: @mode_valid is called from
> + * drm_atomic_helper_check_modeset(), but @atomic_check is called from
> + * drm_atomic_helper_check_planes(), because originally it was meant for
> + * plane update checks only..
Two dots.
Beside this:
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
--
Regards
Andrzej
> *
> * Also beware that userspace can request its own custom modes, neither
> * core nor helpers filter modes to the list of probe modes reported by
> @@ -529,7 +533,9 @@ struct drm_encoder_helper_funcs {
> * allowed.
> *
> * Atomic drivers which need to inspect and adjust more state should
> - * instead use the @atomic_check callback.
> + * instead use the @atomic_check callback. If @atomic_check is used,
> + * this hook isn't called since @atomic_check allows a strict superset
> + * of the functionality of @mode_fixup.
> *
> * Also beware that userspace can request its own custom modes, neither
> * core nor helpers filter modes to the list of probe modes reported by
> @@ -716,6 +722,11 @@ struct drm_encoder_helper_funcs {
> * update the CRTC to match what the encoder needs for the requested
> * connector.
> *
> + * Since this provides a strict superset of the functionality of
> + * @mode_fixup (the requested and adjusted modes are both available
> + * through the passed in &struct drm_crtc_state) @mode_fixup is not
> + * called when @atomic_check is implemented.
> + *
> * This function is used by the atomic helpers, but it is optional.
> *
> * NOTE:
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better
2017-05-15 9:11 ` [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better Daniel Vetter
2017-05-15 9:11 ` [PATCH 2/2] drm/doc: Clarify mode_fixup vs. atomic_check a bit more Daniel Vetter
@ 2017-05-16 2:38 ` Jose Abreu
2017-05-16 13:17 ` Andrzej Hajda
2 siblings, 0 replies; 35+ messages in thread
From: Jose Abreu @ 2017-05-16 2:38 UTC (permalink / raw)
To: Daniel Vetter, DRI Development
Cc: Jose Abreu, Daniel Vetter, Laurent Pinchart
Hi Daniel,
On 15-05-2017 10:11, Daniel Vetter wrote:
> Laurent started a massive discussion on IRC about this. Let's try to
> document common usage a bit better.
>
> v2: Cross-links+typos.
>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Reviewed-by: Jose Abreu <joabreu@synopsys.com>
Best regards,
Jose Miguel Abreu
> ---
> include/drm/drm_bridge.h | 2 +-
> include/drm/drm_crtc.h | 28 +++++++++++++++++++++++++---
> include/drm/drm_modeset_helper_vtables.h | 6 ++++--
> 3 files changed, 30 insertions(+), 6 deletions(-)
>
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index f694de756ecf..f3ad38d0d621 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -91,7 +91,7 @@ struct drm_bridge_funcs {
> * the display chain, either the final &drm_connector or the next
> * &drm_bridge. The parameter adjusted_mode is the input mode the bridge
> * requires. It can be modified by this callback and does not need to
> - * match mode.
> + * match mode. See also &drm_crtc_state.adjusted_mode for more details.
> *
> * This is the only hook that allows a bridge to reject a modeset. If
> * this function passes all other callbacks must succeed for this
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 06236b002c22..5f5d53973ca5 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -90,8 +90,6 @@ struct drm_plane_helper_funcs;
> * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
> * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
> * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
> - * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
> - * @mode: current mode timings
> * @mode_blob: &drm_property_blob for @mode
> * @state: backpointer to global drm_atomic_state
> *
> @@ -131,9 +129,33 @@ struct drm_crtc_state {
> u32 connector_mask;
> u32 encoder_mask;
>
> - /* adjusted_mode: for use by helpers and drivers */
> + /**
> + * @adjusted_mode:
> + *
> + * Internal display timings which can be used by the driver to handle
> + * differences between the mode requested by userspace in @mode and what
> + * is actually programmed into the hardware. It is purely driver
> + * implementation defined what exactly this adjusted mode means. Usually
> + * it is used to store the hardware display timings used between the
> + * CRTC and encoder blocks.
> + */
> struct drm_display_mode adjusted_mode;
>
> + /**
> + * @mode:
> + *
> + * Display timings requested by userspace. The driver should try to
> + * match the refresh rate as close as possible (but note that it's
> + * undefined what exactly is close enough, e.g. some of the HDMI modes
> + * only differ in less than 1% of the refresh rate). The active width
> + * and height as observed by userspace for positioning planes must match
> + * exactly.
> + *
> + * For external connectors where the sink isn't fixed (like with a
> + * built-in panel), this mode here should match the physical mode on the
> + * wire to the last details (i.e. including sync polarities and
> + * everything).
> + */
> struct drm_display_mode mode;
>
> /* blob property to expose current mode to atomic userspace */
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index 91d071ff1232..c72fca544a41 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -138,7 +138,8 @@ struct drm_crtc_helper_funcs {
> * encoders need to be fed with. Note that this is the inverse semantics
> * of the meaning for the &drm_encoder and &drm_bridge_funcs.mode_fixup
> * vfunc. If the CRTC cannot support the requested conversion from mode
> - * to adjusted_mode it should reject the modeset.
> + * to adjusted_mode it should reject the modeset. See also
> + * &drm_crtc_state.adjusted_mode for more details.
> *
> * This function is used by both legacy CRTC helpers and atomic helpers.
> * With atomic helpers it is optional.
> @@ -510,7 +511,8 @@ struct drm_encoder_helper_funcs {
> * mode is the display mode that should be fed to the next element in
> * the display chain, either the final &drm_connector or a &drm_bridge.
> * The parameter adjusted_mode is the input mode the encoder requires. It
> - * can be modified by this callback and does not need to match mode.
> + * can be modified by this callback and does not need to match mode. See
> + * also &drm_crtc_state.adjusted_mode for more details.
> *
> * This function is used by both legacy CRTC helpers and atomic helpers.
> * This hook is optional.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better
2017-05-15 9:11 ` [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better Daniel Vetter
2017-05-15 9:11 ` [PATCH 2/2] drm/doc: Clarify mode_fixup vs. atomic_check a bit more Daniel Vetter
2017-05-16 2:38 ` [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better Jose Abreu
@ 2017-05-16 13:17 ` Andrzej Hajda
2 siblings, 0 replies; 35+ messages in thread
From: Andrzej Hajda @ 2017-05-16 13:17 UTC (permalink / raw)
To: Daniel Vetter, DRI Development
Cc: Jose Abreu, Daniel Vetter, Laurent Pinchart
On 15.05.2017 11:11, Daniel Vetter wrote:
> Laurent started a massive discussion on IRC about this. Let's try to
> document common usage a bit better.
>
> v2: Cross-links+typos.
>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
--
Regards
Andrzej
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
2017-05-12 7:31 ` [PATCH] " Daniel Vetter
` (3 preceding siblings ...)
2017-05-15 9:11 ` [PATCH 1/2] drm/doc: Document adjusted/request modes a bit better Daniel Vetter
@ 2017-05-15 9:33 ` Daniel Vetter
2017-05-16 13:15 ` Andrzej Hajda
4 siblings, 1 reply; 35+ messages in thread
From: Daniel Vetter @ 2017-05-15 9:33 UTC (permalink / raw)
To: DRI Development
Cc: Jose Abreu, Daniel Vetter, Alexey Brodkin, Jose Abreu,
Laurent Pinchart, Carlos Palminha
From: Jose Abreu <Jose.Abreu@synopsys.com>
This adds a new callback to crtc, encoder and bridge helper functions
called mode_valid(). This callback shall be implemented if the
corresponding component has some sort of restriction in the modes
that can be displayed. A NULL callback implicates that the component
can display all the modes.
We also change the documentation so that the new and old callbacks
are correctly documented.
Only the callbacks were implemented to simplify review process,
following patches will make use of them.
Changes in v2 from Daniel:
- Update the warning about how modes aren't filtered in atomic_check -
the heleprs help out a lot more now.
- Consistenly roll out that warning, crtc/encoder's atomic_check
missed it.
- Sprinkle more links all over the place, so it's easier to see where
this stuff is used and how the differen hooks are related.
- Note that ->mode_valid is optional everywhere.
- Explain why the connector's mode_valid is special and does _not_ get
called in atomic_check.
v3: Document what can and cannot be checked in mode_valid a bit better
(Andrjez). Answer: Only allowed to look at the mode, nothing else.
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: Carlos Palminha <palminha@synopsys.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@linux.ie>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2)
---
include/drm/drm_bridge.h | 40 +++++++++
include/drm/drm_modeset_helper_vtables.h | 134 +++++++++++++++++++++++--------
2 files changed, 141 insertions(+), 33 deletions(-)
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index fdd82fcbf168..f703bafc2e30 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -59,6 +59,40 @@ struct drm_bridge_funcs {
void (*detach)(struct drm_bridge *bridge);
/**
+ * @mode_valid:
+ *
+ * This callback is used to check if a specific mode is valid in this
+ * bridge. This should be implemented if the bridge has some sort of
+ * restriction in the modes it can display. For example, a given bridge
+ * may be responsible to set a clock value. If the clock can not
+ * produce all the values for the available modes then this callback
+ * can be used to restrict the number of modes to only the ones that
+ * can be displayed.
+ *
+ * This hook is used by the probe helpers to filter the mode list in
+ * drm_helper_probe_single_connector_modes(), and it is used by the
+ * atomic helpers to validate modes supplied by userspace in
+ * drm_atomic_helper_check_modeset().
+ *
+ * This function is optional.
+ *
+ * NOTE:
+ *
+ * Since this function is both called from the check phase of an atomic
+ * commit, and the mode validation in the probe paths it is not allowed
+ * to look at anything else but the passed-in mode, and validate it
+ * against configuration-invariant hardward constraints. Any further
+ * limits which depend upon the configuration can only be checked in
+ * @mode_fixup.
+ *
+ * RETURNS:
+ *
+ * drm_mode_status Enum
+ */
+ enum drm_mode_status (*mode_valid)(struct drm_bridge *crtc,
+ const struct drm_display_mode *mode);
+
+ /**
* @mode_fixup:
*
* This callback is used to validate and adjust a mode. The paramater
@@ -82,6 +116,12 @@ struct drm_bridge_funcs {
* NOT touch any persistent state (hardware or software) or data
* structures except the passed in @state parameter.
*
+ * Also beware that userspace can request its own custom modes, neither
+ * core nor helpers filter modes to the list of probe modes reported by
+ * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
+ * that modes are filtered consistently put any bridge constraints and
+ * limits checks into @mode_valid.
+ *
* RETURNS:
*
* True if an acceptable configuration is possible, false if the modeset
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index c01c328f6cc8..739b832eb304 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -106,6 +106,40 @@ struct drm_crtc_helper_funcs {
void (*commit)(struct drm_crtc *crtc);
/**
+ * @mode_valid:
+ *
+ * This callback is used to check if a specific mode is valid in this
+ * crtc. This should be implemented if the crtc has some sort of
+ * restriction in the modes it can display. For example, a given crtc
+ * may be responsible to set a clock value. If the clock can not
+ * produce all the values for the available modes then this callback
+ * can be used to restrict the number of modes to only the ones that
+ * can be displayed.
+ *
+ * This hook is used by the probe helpers to filter the mode list in
+ * drm_helper_probe_single_connector_modes(), and it is used by the
+ * atomic helpers to validate modes supplied by userspace in
+ * drm_atomic_helper_check_modeset().
+ *
+ * This function is optional.
+ *
+ * NOTE:
+ *
+ * Since this function is both called from the check phase of an atomic
+ * commit, and the mode validation in the probe paths it is not allowed
+ * to look at anything else but the passed-in mode, and validate it
+ * against configuration-invariant hardward constraints. Any further
+ * limits which depend upon the configuration can only be checked in
+ * @mode_fixup or @atomic_check.
+ *
+ * RETURNS:
+ *
+ * drm_mode_status Enum
+ */
+ enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
+ const struct drm_display_mode *mode);
+
+ /**
* @mode_fixup:
*
* This callback is used to validate a mode. The parameter mode is the
@@ -132,20 +166,11 @@ struct drm_crtc_helper_funcs {
* Atomic drivers which need to inspect and adjust more state should
* instead use the @atomic_check callback.
*
- * Also beware that neither core nor helpers filter modes before
- * passing them to the driver: While the list of modes that is
- * advertised to userspace is filtered using the
- * &drm_connector.mode_valid callback, neither the core nor the helpers
- * do any filtering on modes passed in from userspace when setting a
- * mode. It is therefore possible for userspace to pass in a mode that
- * was previously filtered out using &drm_connector.mode_valid or add a
- * custom mode that wasn't probed from EDID or similar to begin with.
- * Even though this is an advanced feature and rarely used nowadays,
- * some users rely on being able to specify modes manually so drivers
- * must be prepared to deal with it. Specifically this means that all
- * drivers need not only validate modes in &drm_connector.mode_valid but
- * also in this or in the &drm_encoder_helper_funcs.mode_fixup callback
- * to make sure invalid modes passed in from userspace are rejected.
+ * Also beware that userspace can request its own custom modes, neither
+ * core nor helpers filter modes to the list of probe modes reported by
+ * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
+ * that modes are filtered consistently put any CRTC constraints and
+ * limits checks into @mode_valid.
*
* RETURNS:
*
@@ -341,6 +366,12 @@ struct drm_crtc_helper_funcs {
* state objects passed-in or assembled in the overall &drm_atomic_state
* update tracking structure.
*
+ * Also beware that userspace can request its own custom modes, neither
+ * core nor helpers filter modes to the list of probe modes reported by
+ * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
+ * that modes are filtered consistently put any CRTC constraints and
+ * limits checks into @mode_valid.
+ *
* RETURNS:
*
* 0 on success, -EINVAL if the state or the transition can't be
@@ -457,6 +488,40 @@ struct drm_encoder_helper_funcs {
void (*dpms)(struct drm_encoder *encoder, int mode);
/**
+ * @mode_valid:
+ *
+ * This callback is used to check if a specific mode is valid in this
+ * encoder. This should be implemented if the encoder has some sort
+ * of restriction in the modes it can display. For example, a given
+ * encoder may be responsible to set a clock value. If the clock can
+ * not produce all the values for the available modes then this callback
+ * can be used to restrict the number of modes to only the ones that
+ * can be displayed.
+ *
+ * This hook is used by the probe helpers to filter the mode list in
+ * drm_helper_probe_single_connector_modes(), and it is used by the
+ * atomic helpers to validate modes supplied by userspace in
+ * drm_atomic_helper_check_modeset().
+ *
+ * This function is optional.
+ *
+ * NOTE:
+ *
+ * Since this function is both called from the check phase of an atomic
+ * commit, and the mode validation in the probe paths it is not allowed
+ * to look at anything else but the passed-in mode, and validate it
+ * against configuration-invariant hardward constraints. Any further
+ * limits which depend upon the configuration can only be checked in
+ * @mode_fixup or @atomic_check.
+ *
+ * RETURNS:
+ *
+ * drm_mode_status Enum
+ */
+ enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
+ const struct drm_display_mode *mode);
+
+ /**
* @mode_fixup:
*
* This callback is used to validate and adjust a mode. The parameter
@@ -482,21 +547,11 @@ struct drm_encoder_helper_funcs {
* Atomic drivers which need to inspect and adjust more state should
* instead use the @atomic_check callback.
*
- * Also beware that neither core nor helpers filter modes before
- * passing them to the driver: While the list of modes that is
- * advertised to userspace is filtered using the connector's
- * &drm_connector_helper_funcs.mode_valid callback, neither the core nor
- * the helpers do any filtering on modes passed in from userspace when
- * setting a mode. It is therefore possible for userspace to pass in a
- * mode that was previously filtered out using
- * &drm_connector_helper_funcs.mode_valid or add a custom mode that
- * wasn't probed from EDID or similar to begin with. Even though this
- * is an advanced feature and rarely used nowadays, some users rely on
- * being able to specify modes manually so drivers must be prepared to
- * deal with it. Specifically this means that all drivers need not only
- * validate modes in &drm_connector.mode_valid but also in this or in
- * the &drm_crtc_helper_funcs.mode_fixup callback to make sure
- * invalid modes passed in from userspace are rejected.
+ * Also beware that userspace can request its own custom modes, neither
+ * core nor helpers filter modes to the list of probe modes reported by
+ * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
+ * that modes are filtered consistently put any encoder constraints and
+ * limits checks into @mode_valid.
*
* RETURNS:
*
@@ -686,6 +741,12 @@ struct drm_encoder_helper_funcs {
* state objects passed-in or assembled in the overall &drm_atomic_state
* update tracking structure.
*
+ * Also beware that userspace can request its own custom modes, neither
+ * core nor helpers filter modes to the list of probe modes reported by
+ * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
+ * that modes are filtered consistently put any encoder constraints and
+ * limits checks into @mode_valid.
+ *
* RETURNS:
*
* 0 on success, -EINVAL if the state or the transition can't be
@@ -795,13 +856,20 @@ struct drm_connector_helper_funcs {
* (which is usually derived from the EDID data block from the sink).
* See e.g. drm_helper_probe_single_connector_modes().
*
+ * This function is optional.
+ *
* NOTE:
*
* This only filters the mode list supplied to userspace in the
- * GETCONNECOTR IOCTL. Userspace is free to create modes of its own and
- * ask the kernel to use them. It this case the atomic helpers or legacy
- * CRTC helpers will not call this function. Drivers therefore must
- * still fully validate any mode passed in in a modeset request.
+ * GETCONNECTOR IOCTL. Compared to &drm_encoder_helper_funcs.mode_valid,
+ * &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
+ * which are also called by the atomic helpers from
+ * drm_atomic_helper_check_modeset(). This allows userspace to force and
+ * ignore sink constraint (like the pixel clock limits in the screen's
+ * EDID), which is useful for e.g. testing, or working around a broken
+ * EDID. Any source hardware constraint (which always need to be
+ * enforced) therefore should be checked in one of the above callbacks,
+ * and not this one here.
*
* To avoid races with concurrent connector state updates, the helper
* libraries always call this with the &drm_mode_config.connection_mutex
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 35+ messages in thread* Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
2017-05-15 9:33 ` [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks Daniel Vetter
@ 2017-05-16 13:15 ` Andrzej Hajda
0 siblings, 0 replies; 35+ messages in thread
From: Andrzej Hajda @ 2017-05-16 13:15 UTC (permalink / raw)
To: Daniel Vetter, DRI Development
Cc: Jose Abreu, Alexey Brodkin, Jose Abreu, Laurent Pinchart,
Carlos Palminha
On 15.05.2017 11:33, Daniel Vetter wrote:
> From: Jose Abreu <Jose.Abreu@synopsys.com>
>
> This adds a new callback to crtc, encoder and bridge helper functions
> called mode_valid(). This callback shall be implemented if the
> corresponding component has some sort of restriction in the modes
> that can be displayed. A NULL callback implicates that the component
> can display all the modes.
>
> We also change the documentation so that the new and old callbacks
> are correctly documented.
>
> Only the callbacks were implemented to simplify review process,
> following patches will make use of them.
>
> Changes in v2 from Daniel:
> - Update the warning about how modes aren't filtered in atomic_check -
> the heleprs help out a lot more now.
> - Consistenly roll out that warning, crtc/encoder's atomic_check
> missed it.
> - Sprinkle more links all over the place, so it's easier to see where
> this stuff is used and how the differen hooks are related.
> - Note that ->mode_valid is optional everywhere.
> - Explain why the connector's mode_valid is special and does _not_ get
> called in atomic_check.
>
> v3: Document what can and cannot be checked in mode_valid a bit better
> (Andrjez). Answer: Only allowed to look at the mode, nothing else.
>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> Cc: Jose Abreu <joabreu@synopsys.com>
> Cc: Carlos Palminha <palminha@synopsys.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Dave Airlie <airlied@linux.ie>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Archit Taneja <architt@codeaurora.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2)
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
--
Regards
Andrzej
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 35+ messages in thread