[PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
From: Jose Abreu 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 Cc: Jose Abreu Cc: Carlos Palminha Cc: Alexey Brodkin Cc: Ville Syrjälä Cc: Daniel Vetter Cc: Dave Airlie Cc: Andrzej Hajda Cc: Archit Taneja Signed-off-by: Daniel Vetter (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_m
[PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
From: Jose Abreu 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 Signed-off-by: Jose Abreu Cc: Jose Abreu Cc: Carlos Palminha Cc: Alexey Brodkin Cc: Ville Syrjälä Cc: Daniel Vetter Cc: Dave Airlie Cc: Andrzej Hajda Cc: Archit Taneja Signed-off-by: Daniel Vetter (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 nu
Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
Hi Daniel, On Friday 12 May 2017 09:31:00 Daniel Vetter wrote: > From: Jose Abreu > > 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 > Cc: Jose Abreu > Cc: Carlos Palminha > Cc: Alexey Brodkin > Cc: Ville Syrjälä > Cc: Daniel Vetter > Cc: Dave Airlie > Cc: Andrzej Hajda > Cc: Archit Taneja > Signed-off-by: Daniel Vetter (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
Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
On 12.05.2017 09:31, Daniel Vetter wrote: > From: Jose Abreu > > 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 > Cc: Jose Abreu > Cc: Carlos Palminha > Cc: Alexey Brodkin > Cc: Ville Syrjälä > Cc: Daniel Vetter > Cc: Dave Airlie > Cc: Andrzej Hajda > Cc: Archit Taneja > Signed-off-by: Daniel Vetter (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 h
Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
Hi Daniel, On 12-05-2017 08:31, Daniel Vetter wrote: > From: Jose Abreu > > 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 > Cc: Jose Abreu > Cc: Carlos Palminha > Cc: Alexey Brodkin > Cc: Ville Syrjälä > Cc: Daniel Vetter > Cc: Dave Airlie > Cc: Andrzej Hajda > Cc: Archit Taneja > Signed-off-by: Daniel Vetter (v2) Thanks! Looks fine by me. Reviewed-by: Jose Abreu 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(). > + * > + *
Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
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 > > > > 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 > > Cc: Jose Abreu > > Cc: Carlos Palminha > > Cc: Alexey Brodkin > > Cc: Ville Syrjälä > > Cc: Daniel Vetter > > Cc: Dave Airlie > > Cc: Andrzej Hajda > > Cc: Archit Taneja > > Signed-off-by: Daniel Vetter (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
Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
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 > > > > 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 > > Cc: Jose Abreu > > Cc: Carlos Palminha > > Cc: Alexey Brodkin > > Cc: Ville Syrjälä > > Cc: Daniel Vetter > > Cc: Dave Airlie > > Cc: Andrzej Hajda > > Cc: Archit Taneja > > Signed-off-by: Daniel Vetter (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
Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
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 >>> >>> 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 >>> Cc: Jose Abreu >>> Cc: Carlos Palminha >>> Cc: Alexey Brodkin >>> Cc: Ville Syrjälä >>> Cc: Daniel Vetter >>> Cc: Dave Airlie >>> Cc: Andrzej Hajda >>> Cc: Archit Taneja >>> Signed-off-by: Daniel Vetter (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
Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
On Mon, May 15, 2017 at 10:10 AM, Andrzej Hajda 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
Re: [PATCH] drm: Add crtc/encoder/bridge->mode_valid() callbacks
On 15.05.2017 11:33, Daniel Vetter wrote: > From: Jose Abreu > > 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 > Signed-off-by: Jose Abreu > Cc: Jose Abreu > Cc: Carlos Palminha > Cc: Alexey Brodkin > Cc: Ville Syrjälä > Cc: Daniel Vetter > Cc: Dave Airlie > Cc: Andrzej Hajda > Cc: Archit Taneja > Signed-off-by: Daniel Vetter (v2) Reviewed-by: Andrzej Hajda -- Regards Andrzej ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel