[PATCH v2 weston 02/16] compositor-drm: Refactor connector name into new function

Bryce Harrington bryce at osg.samsung.com
Fri Jul 10 17:49:56 PDT 2015


On Mon, Jun 22, 2015 at 05:25:07PM +0100, Daniel Stone wrote:
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> Refactor the code constructing the connector name into a new function.
> This makes create_output_for_connector() slightly easier to read.
> 
> Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> Signed-off-by: Daniel Stone <daniels at collabora.com>
Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>

Also a simple refactor that could land early.  But doesn't apply
presently.

Bryce

> ---
>  src/compositor-drm.c | 28 ++++++++++++++++++----------
>  1 file changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index 60f07f1..25a4567 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -1610,7 +1610,7 @@ drm_set_dpms(struct weston_output *output_base, enum dpms_enum level)
>  				    output->dpms_prop->prop_id, level);
>  }
>  
> -static const char *connector_type_names[] = {
> +static const char * const connector_type_names[] = {
>  	"None",
>  	"VGA",
>  	"DVI",
> @@ -1628,6 +1628,21 @@ static const char *connector_type_names[] = {
>  	"eDP",
>  };
>  
> +static char *
> +make_connector_name(const drmModeConnector *con)
> +{
> +	char name[32];
> +	const char *type_name;
> +
> +	if (con->connector_type < ARRAY_LENGTH(connector_type_names))
> +		type_name = connector_type_names[con->connector_type];
> +	else
> +		type_name = "UNKNOWN";
> +	snprintf(name, sizeof name, "%s%d", type_name, con->connector_type_id);
> +
> +	return strdup(name);
> +}
> +
>  static int
>  find_crtc_for_connector(struct drm_compositor *ec,
>  			drmModeRes *resources, drmModeConnector *connector)
> @@ -2103,8 +2118,7 @@ create_output_for_connector(struct drm_compositor *ec,
>  	drmModeModeInfo crtc_mode, modeline;
>  	drmModeCrtc *crtc;
>  	int i, width, height, scale;
> -	char name[32], *s;
> -	const char *type_name;
> +	char *s;
>  	enum output_config config;
>  	uint32_t transform;
>  
> @@ -2119,18 +2133,12 @@ create_output_for_connector(struct drm_compositor *ec,
>  		return -1;
>  
>  	output->base.subpixel = drm_subpixel_to_wayland(connector->subpixel);
> +	output->base.name = make_connector_name(connector);
>  	output->base.make = "unknown";
>  	output->base.model = "unknown";
>  	output->base.serial_number = "unknown";
>  	wl_list_init(&output->base.mode_list);
>  
> -	if (connector->connector_type < ARRAY_LENGTH(connector_type_names))
> -		type_name = connector_type_names[connector->connector_type];
> -	else
> -		type_name = "UNKNOWN";
> -	snprintf(name, 32, "%s%d", type_name, connector->connector_type_id);
> -	output->base.name = strdup(name);
> -
>  	section = weston_config_get_section(ec->base.config, "output", "name",
>  					    output->base.name);
>  	weston_config_section_get_string(section, "mode", &s, "preferred");
> -- 
> 2.4.3
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list