[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z5uDJ00o6Hqm6i9a@louis-chauvet-laptop>
Date: Thu, 30 Jan 2025 14:48:23 +0100
From: Louis Chauvet <louis.chauvet@...tlin.com>
To: José Expósito <jose.exposito89@...il.com>
Cc: hamohammed.sa@...il.com, simona@...ll.ch, melissa.srw@...il.com,
maarten.lankhorst@...ux.intel.com, mripard@...nel.org,
tzimmermann@...e.de, airlied@...il.com,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 10/13] drm/vkms: Allow to configure multiple encoders
On 29/01/25 - 12:00, José Expósito wrote:
> Add a list of encoders to vkms_config and helper functions to add and
> remove as many encoders as wanted.
>
> For backwards compatibility, add one encoder to the default
> configuration.
>
> A future patch will allow to attach encoders and CRTCs, but for the
> moment there are no changes in the way the output is configured.
>
> Signed-off-by: Louis Chauvet <louis.chauvet@...tlin.com>
> Signed-off-by: José Expósito <jose.exposito89@...il.com>
Co-developped-by: Louis Chauvet <louis.chauvet@...tlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@...tlin.com>
Signed-off-by: José Expósito <jose.exposito89@...il.com>
[...]
> +static void vkms_config_test_valid_encoder_number(struct kunit *test)
Same as before, can you rename to vkms_config_test_invalid_encoder_number
> +{
> + struct vkms_config *config;
> + struct vkms_config_encoder *encoder_cfg;
> + int n;
> +
> + config = vkms_config_default_create(false, false, false);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
> +
> + /* Invalid: No encoders */
> + encoder_cfg = list_first_entry(&config->encoders, typeof(*encoder_cfg), link);
> + vkms_config_destroy_encoder(config, encoder_cfg);
> + KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
> +
> + /* Invalid: Too many encoders */
> + for (n = 0; n <= 32; n++)
> + vkms_config_add_encoder(config);
> +
> + KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
> +
> + vkms_config_destroy(config);
> +}
> +
[...]
> +struct vkms_config_encoder **vkms_config_get_encoders(const struct vkms_config *config,
> + size_t *out_length)
> +{
> + struct vkms_config_encoder **array;
> + struct vkms_config_encoder *encoder_cfg;
> + size_t length;
> + int n = 0;
> +
> + length = list_count_nodes((struct list_head *)&config->encoders);
> + if (length == 0) {
> + *out_length = length;
> + return NULL;
> + }
> +
> + array = kmalloc_array(length, sizeof(*array), GFP_KERNEL);
> + if (!array)
> + return ERR_PTR(-ENOMEM);
> +
> + list_for_each_entry(encoder_cfg, &config->encoders, link) {
> + array[n] = encoder_cfg;
> + n++;
> + }
> +
> + *out_length = length;
> + return array;
> +}
Same as before, can we use an iterator?
> +struct vkms_config_encoder *vkms_config_add_encoder(struct vkms_config *config)
> +{
> + struct vkms_config_encoder *encoder_cfg;
> +
> + encoder_cfg = kzalloc(sizeof(*encoder_cfg), GFP_KERNEL);
> + if (!encoder_cfg)
> + return ERR_PTR(-ENOMEM);
> +
> + list_add_tail(&encoder_cfg->link, &config->encoders);
> +
> + return encoder_cfg;
> +}
> +
> +void vkms_config_destroy_encoder(struct vkms_config *config,
> + struct vkms_config_encoder *encoder_cfg)
> +{
> + list_del(&encoder_cfg->link);
> + kfree(encoder_cfg);
> +}
Same as before, can we change the add/destroy naming?
Powered by blists - more mailing lists