[PATCH weston v12 14/40] compositor-drm: Add to_drm_mode helper

Pekka Paalanen ppaalanen at gmail.com
Wed Oct 4 09:27:48 UTC 2017


On Tue, 26 Sep 2017 18:15:47 +0100
Daniel Stone <daniels at collabora.com> wrote:

> Much like we already have to_drm_output and to_drm_backend.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  libweston/compositor-drm.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 2a72456d..3c75ec56 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -479,6 +479,12 @@ drm_output_pageflip_timer_create(struct drm_output *output)
>  	return 0;
>  }
>  
> +static inline struct drm_mode *
> +to_drm_mode(struct weston_mode *base)
> +{
> +	return container_of(base, struct drm_mode, base);
> +}
> +
>  /**
>   * Get the current value of a KMS property
>   *
> @@ -1788,7 +1794,7 @@ drm_output_apply_state(struct drm_output_state *state)
>  	assert(scanout_state->dest_w == scanout_state->src_w >> 16);
>  	assert(scanout_state->dest_h == scanout_state->src_h >> 16);
>  
> -	mode = container_of(output->base.current_mode, struct drm_mode, base);
> +	mode = to_drm_mode(output->base.current_mode);
>  	if (backend->state_invalid || !scanout_plane->state_cur->fb ||
>  	    scanout_plane->state_cur->fb->stride != scanout_state->fb->stride) {
>  		ret = drmModeSetCrtc(backend->drm.fd, output->crtc_id,

Hi,

as mentioned in IRC, this misses the cast in choose_mode(). That fixed:
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

choose_mode() also has a sneaky secret cast in the wl_list_for_each()
statement. It does not do any harm in this particular case, but I have
tried to weed them out for drm_output casts because in the far future
we might have more than one type of outputs which makes the cast
without a type check dangerous. A type check will be easy to add in
to_drm_output().


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20171004/d0fc3fea/attachment.sig>


More information about the wayland-devel mailing list