All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ander Conselvan De Oliveira <conselvan2@gmail.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH i-g-t v2 02/15] igt_kms: Find optimal encoder only after selecting pipe
Date: Fri, 15 Jul 2016 14:14:10 +0300	[thread overview]
Message-ID: <1468581250.2597.7.camel@gmail.com> (raw)
In-Reply-To: <1467798955-7324-3-git-send-email-maarten.lankhorst@linux.intel.com>

On Wed, 2016-07-06 at 11:55 +0200, Maarten Lankhorst wrote:
> This will allow us to find a matching encoder based on a pipe only.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  lib/igt_kms.c | 97 +++++++++++++++++++++++++++++++++++++---------------------
> -
>  1 file changed, 61 insertions(+), 36 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index c16e40ea273b..ce8aa2455348 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -761,6 +761,59 @@ bool kmstest_get_connector_default_mode(int drm_fd,
> drmModeConnector *connector,
>  	return true;
>  }
>  
> +static void
> +_kmstest_connector_config_crtc_mask(int drm_fd,
> +				    drmModeConnector *connector,
> +				    struct kmstest_connector_config *config)
> +{
> +	int i;
> +
> +	config->valid_crtc_idx_mask = 0;
> +
> +	/* Now get a compatible encoder */
> +	for (i = 0; i < connector->count_encoders; i++) {
> +		drmModeEncoder *encoder = drmModeGetEncoder(drm_fd,
> +							    connector-
> >encoders[i]);
> +
> +		if (!encoder) {
> +			igt_warn("could not get encoder %d: %s\n",
> +				 connector->encoders[i],
> +				 strerror(errno));
> +
> +			continue;
> +		}
> +
> +		config->valid_crtc_idx_mask |= encoder->possible_crtcs;
> +		drmModeFreeEncoder(encoder);
> +	}
> +}
> +
> +static drmModeEncoder *
> +_kmstest_connector_config_find_encoder(int drm_fd, drmModeConnector
> *connector, enum pipe pipe)
> +{
> +	int i;
> +
> +	for (i = 0; i < connector->count_encoders; i++) {
> +		drmModeEncoder *encoder = drmModeGetEncoder(drm_fd,
> connector->encoders[i]);
> +
> +		if (!encoder) {
> +			igt_warn("could not get encoder %d: %s\n",
> +				 connector->encoders[i],
> +				 strerror(errno));
> +
> +			continue;
> +		}
> +
> +		if (encoder->possible_crtcs & (1 << pipe))
> +			return encoder;
> +
> +		drmModeFreeEncoder(encoder);
> +	}
> +
> +	igt_assert(false);
> +	return NULL;
> +}
> +
>  /**
>   * _kmstest_connector_config:
>   * @drm_fd: DRM fd
> @@ -779,8 +832,6 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t
> connector_id,
>  {
>  	drmModeRes *resources;
>  	drmModeConnector *connector;
> -	drmModeEncoder *encoder, *found = NULL;
> -	int i, j, pipe;
>  
>  	resources = drmModeGetResources(drm_fd);
>  	if (!resources) {
> @@ -816,51 +867,25 @@ static bool _kmstest_connector_config(int drm_fd,
> uint32_t connector_id,
>  	 * In both cases find the first compatible encoder and skip the CRTC
>  	 * if there is non such.
>  	 */
> -	config->valid_crtc_idx_mask = 0;
> -	for (i = 0; i < resources->count_crtcs; i++) {
> -		if (!resources->crtcs[i])
> -			continue;

This patch looses the NULL check above, but if I understand correctly this can't
happen anyway, since we would have bailed on a GetResources failure. So,

Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>


> +	_kmstest_connector_config_crtc_mask(drm_fd, connector, config);
>  
> -		/* Now get a compatible encoder */
> -		for (j = 0; j < connector->count_encoders; j++) {
> -			encoder = drmModeGetEncoder(drm_fd,
> -						    connector->encoders[j]);
> -
> -			if (!encoder) {
> -				igt_warn("could not get encoder %d: %s\n",
> -					 resources->encoders[j],
> -					 strerror(errno));
> -
> -				continue;
> -			}
> -
> -			config->valid_crtc_idx_mask |= encoder-
> >possible_crtcs;
> -
> -			if (!found && (crtc_idx_mask & encoder-
> >possible_crtcs & (1 << i))) {
> -				found = encoder;
> -				pipe = i;
> -			} else
> -				drmModeFreeEncoder(encoder);
> -		}
> -	}
> -
> -	if (!found)
> +	crtc_idx_mask &= config->valid_crtc_idx_mask;
> +	if (!crtc_idx_mask)
>  		goto err3;
>  
> +	config->pipe = ffs(crtc_idx_mask) - 1;
> +
>  	if (!kmstest_get_connector_default_mode(drm_fd, connector,
>  						&config->default_mode))
> -		goto err4;
> +		goto err3;
>  
> +	config->encoder = _kmstest_connector_config_find_encoder(drm_fd,
> connector, config->pipe);
>  	config->connector = connector;
> -	config->encoder = found;
> -	config->crtc = drmModeGetCrtc(drm_fd, resources->crtcs[pipe]);
> -	config->pipe = pipe;
> +	config->crtc = drmModeGetCrtc(drm_fd, resources->crtcs[config-
> >pipe]);
>  
>  	drmModeFreeResources(resources);
>  
>  	return true;
> -err4:
> -	drmModeFreeEncoder(found);
>  err3:
>  	drmModeFreeConnector(connector);
>  err2:
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-07-15 11:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06  9:55 [PATCH i-g-t v2 00/15] Add support for atomic modeset to IGT Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 01/15] igt_kms: Remove kmstest_connector_config.crtc_idx Maarten Lankhorst
2016-07-13 12:13   ` Daniel Vetter
2016-07-19 12:52     ` Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 02/15] igt_kms: Find optimal encoder only after selecting pipe Maarten Lankhorst
2016-07-15 11:14   ` Ander Conselvan De Oliveira [this message]
2016-07-06  9:55 ` [PATCH i-g-t v2 03/15] kms_psr_sink_crc: Use for_each_pipe_with_valid_output to find a valid config Maarten Lankhorst
2016-07-15 11:15   ` Ander Conselvan De Oliveira
2016-07-19 13:58     ` Ander Conselvan De Oliveira
2016-07-20  7:53       ` Maarten Lankhorst
2016-07-20 12:17         ` Ander Conselvan De Oliveira
2016-07-06  9:55 ` [PATCH i-g-t v2 04/15] igt_kms: Make PIPE_ANY a alias for PIPE_NONE Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 05/15] tests/kms: Clean up more users of unassigned pipes Maarten Lankhorst
2016-07-20 12:56   ` Ander Conselvan De Oliveira
2016-07-21  9:21     ` Maarten Lankhorst
2016-07-25 13:04     ` Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 06/15] igt_kms: Change PIPE_ANY behavior to mean unassigned Maarten Lankhorst
2016-07-21  9:23   ` Ander Conselvan De Oliveira
2016-07-06  9:55 ` [PATCH i-g-t v2 07/15] igt_kms: Handle atomic pipe properties better Maarten Lankhorst
2016-07-21 10:07   ` Ander Conselvan De Oliveira
2016-07-06  9:55 ` [PATCH i-g-t v2 08/15] igt_kms: Remove pan members from igt_plane, v2 Maarten Lankhorst
2016-07-21 11:42   ` Ander Conselvan De Oliveira
2016-07-21 12:37     ` Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 09/15] igt_kms: Clear all _changed members centrally Maarten Lankhorst
2016-07-21 12:13   ` Ander Conselvan De Oliveira
2016-07-21 12:43     ` Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 10/15] igt_kms: Add modeset support to atomic commits Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 11/15] tests: Add kms_rmfb test Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 12/15] tests: Add kms_atomic_transition Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 13/15] igt_kms: Add more apis for panel fitting test Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 14/15] igt_kms: Allow disabling previous override mode Maarten Lankhorst
2016-07-06  9:55 ` [PATCH i-g-t v2 15/15] kms_panel_fitting: Add tests for fastboot Maarten Lankhorst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468581250.2597.7.camel@gmail.com \
    --to=conselvan2@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.