Skip to content

Commit 0d6dcd7

Browse files
armurthysurajk8
authored andcommitted
drm/plane: modify create_in_formats to acommodate async
create_in_formats creates the list of supported format/modifiers for synchronous flips, modify the same function so as to take the format_mod_supported as argument and create list of format/modifier for async as well. v5: create_in_formats can return -ve value in failure case, correct the if condition to check the creation of blob <Chaitanya> Dont add the modifier for which none of the formats is not supported. v6: Remove the code for masking the unsupported modifiers as UMD can leave with it. (Naveen/Chaitanya) v7: Retain the unsupported modifiers, userspace should have no impact, return pointer to blob instead of blob_id(Ville) Signed-off-by: Arun R Murthy <[email protected]> Acked-by: Xaver Hugl <[email protected]> Acked-by: Harry Wentland <[email protected]> Reviewed-by: Chaitanya Kumar Borah <[email protected]> Reviewed-by: Ville Syrjälä <[email protected]> Tested-by: Naveen Kumar <[email protected]> Signed-off-by: Suraj Kandpal <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9cd5cc9 commit 0d6dcd7

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

drivers/gpu/drm/drm_plane.c

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,13 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
193193
return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
194194
}
195195

196-
static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
196+
static struct drm_property_blob *create_in_format_blob(struct drm_device *dev,
197+
struct drm_plane *plane,
198+
bool (*format_mod_supported)
199+
(struct drm_plane *plane,
200+
u32 format,
201+
u64 modifier))
197202
{
198-
const struct drm_mode_config *config = &dev->mode_config;
199203
struct drm_property_blob *blob;
200204
struct drm_format_modifier *mod;
201205
size_t blob_size, formats_size, modifiers_size;
@@ -221,7 +225,7 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
221225

222226
blob = drm_property_create_blob(dev, blob_size, NULL);
223227
if (IS_ERR(blob))
224-
return -1;
228+
return NULL;
225229

226230
blob_data = blob->data;
227231
blob_data->version = FORMAT_BLOB_CURRENT;
@@ -237,10 +241,10 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
237241
mod = modifiers_ptr(blob_data);
238242
for (i = 0; i < plane->modifier_count; i++) {
239243
for (j = 0; j < plane->format_count; j++) {
240-
if (!plane->funcs->format_mod_supported ||
241-
plane->funcs->format_mod_supported(plane,
242-
plane->format_types[j],
243-
plane->modifiers[i])) {
244+
if (!format_mod_supported ||
245+
format_mod_supported(plane,
246+
plane->format_types[j],
247+
plane->modifiers[i])) {
244248
mod->formats |= 1ULL << j;
245249
}
246250
}
@@ -251,10 +255,7 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
251255
mod++;
252256
}
253257

254-
drm_object_attach_property(&plane->base, config->modifiers_property,
255-
blob->base.id);
256-
257-
return 0;
258+
return blob;
258259
}
259260

260261
/**
@@ -366,6 +367,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
366367
const char *name, va_list ap)
367368
{
368369
struct drm_mode_config *config = &dev->mode_config;
370+
struct drm_property_blob *blob;
369371
static const uint64_t default_modifiers[] = {
370372
DRM_FORMAT_MOD_LINEAR,
371373
};
@@ -477,8 +479,24 @@ static int __drm_universal_plane_init(struct drm_device *dev,
477479
drm_plane_create_hotspot_properties(plane);
478480
}
479481

480-
if (format_modifier_count)
481-
create_in_format_blob(dev, plane);
482+
if (format_modifier_count) {
483+
blob = create_in_format_blob(dev, plane,
484+
plane->funcs->format_mod_supported);
485+
if (!IS_ERR(blob))
486+
drm_object_attach_property(&plane->base,
487+
config->modifiers_property,
488+
blob->base.id);
489+
}
490+
491+
if (plane->funcs->format_mod_supported_async) {
492+
blob = create_in_format_blob(dev, plane,
493+
plane->funcs->format_mod_supported_async);
494+
if (!IS_ERR(blob))
495+
drm_object_attach_property(&plane->base,
496+
config->async_modifiers_property,
497+
blob->base.id);
498+
}
499+
482500

483501
return 0;
484502
}

0 commit comments

Comments
 (0)