mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 21:54:11 +08:00
drm/drm_property: make replace_property_blob_from_id a DRM helper
Place it in drm_property where drm_property_replace_blob and drm_property_lookup_blob live. Then we can use the DRM helper for driver-specific KMS properties too. Reviewed-by: Harry Wentland <harry.wentland@amd.com> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Signed-off-by: Melissa Wen <mwen@igalia.com> Acked-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
1e13c5644c
commit
6016031053
@ -221,7 +221,7 @@ static int malidp_crtc_atomic_check_ctm(struct drm_crtc *crtc,
|
||||
|
||||
/*
|
||||
* The size of the ctm is checked in
|
||||
* drm_atomic_replace_property_blob_from_id.
|
||||
* drm_property_replace_blob_from_id.
|
||||
*/
|
||||
ctm = (struct drm_color_ctm *)state->ctm->data;
|
||||
for (i = 0; i < ARRAY_SIZE(ctm->matrix); ++i) {
|
||||
|
@ -362,48 +362,6 @@ static s32 __user *get_out_fence_for_connector(struct drm_atomic_state *state,
|
||||
return fence_ptr;
|
||||
}
|
||||
|
||||
static int
|
||||
drm_atomic_replace_property_blob_from_id(struct drm_device *dev,
|
||||
struct drm_property_blob **blob,
|
||||
uint64_t blob_id,
|
||||
ssize_t expected_size,
|
||||
ssize_t expected_elem_size,
|
||||
bool *replaced)
|
||||
{
|
||||
struct drm_property_blob *new_blob = NULL;
|
||||
|
||||
if (blob_id != 0) {
|
||||
new_blob = drm_property_lookup_blob(dev, blob_id);
|
||||
if (new_blob == NULL) {
|
||||
drm_dbg_atomic(dev,
|
||||
"cannot find blob ID %llu\n", blob_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (expected_size > 0 &&
|
||||
new_blob->length != expected_size) {
|
||||
drm_dbg_atomic(dev,
|
||||
"[BLOB:%d] length %zu different from expected %zu\n",
|
||||
new_blob->base.id, new_blob->length, expected_size);
|
||||
drm_property_blob_put(new_blob);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (expected_elem_size > 0 &&
|
||||
new_blob->length % expected_elem_size != 0) {
|
||||
drm_dbg_atomic(dev,
|
||||
"[BLOB:%d] length %zu not divisible by element size %zu\n",
|
||||
new_blob->base.id, new_blob->length, expected_elem_size);
|
||||
drm_property_blob_put(new_blob);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
*replaced |= drm_property_replace_blob(blob, new_blob);
|
||||
drm_property_blob_put(new_blob);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
|
||||
struct drm_crtc_state *state, struct drm_property *property,
|
||||
uint64_t val)
|
||||
@ -424,7 +382,7 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
|
||||
} else if (property == config->prop_vrr_enabled) {
|
||||
state->vrr_enabled = val;
|
||||
} else if (property == config->degamma_lut_property) {
|
||||
ret = drm_atomic_replace_property_blob_from_id(dev,
|
||||
ret = drm_property_replace_blob_from_id(dev,
|
||||
&state->degamma_lut,
|
||||
val,
|
||||
-1, sizeof(struct drm_color_lut),
|
||||
@ -432,7 +390,7 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
|
||||
state->color_mgmt_changed |= replaced;
|
||||
return ret;
|
||||
} else if (property == config->ctm_property) {
|
||||
ret = drm_atomic_replace_property_blob_from_id(dev,
|
||||
ret = drm_property_replace_blob_from_id(dev,
|
||||
&state->ctm,
|
||||
val,
|
||||
sizeof(struct drm_color_ctm), -1,
|
||||
@ -440,7 +398,7 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
|
||||
state->color_mgmt_changed |= replaced;
|
||||
return ret;
|
||||
} else if (property == config->gamma_lut_property) {
|
||||
ret = drm_atomic_replace_property_blob_from_id(dev,
|
||||
ret = drm_property_replace_blob_from_id(dev,
|
||||
&state->gamma_lut,
|
||||
val,
|
||||
-1, sizeof(struct drm_color_lut),
|
||||
@ -581,7 +539,7 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
|
||||
} else if (property == plane->color_range_property) {
|
||||
state->color_range = val;
|
||||
} else if (property == config->prop_fb_damage_clips) {
|
||||
ret = drm_atomic_replace_property_blob_from_id(dev,
|
||||
ret = drm_property_replace_blob_from_id(dev,
|
||||
&state->fb_damage_clips,
|
||||
val,
|
||||
-1,
|
||||
@ -778,7 +736,7 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
|
||||
if (state->link_status != DRM_LINK_STATUS_GOOD)
|
||||
state->link_status = val;
|
||||
} else if (property == config->hdr_output_metadata_property) {
|
||||
ret = drm_atomic_replace_property_blob_from_id(dev,
|
||||
ret = drm_property_replace_blob_from_id(dev,
|
||||
&state->hdr_output_metadata,
|
||||
val,
|
||||
sizeof(struct hdr_output_metadata), -1,
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <drm/drm_drv.h>
|
||||
#include <drm/drm_file.h>
|
||||
#include <drm/drm_framebuffer.h>
|
||||
#include <drm/drm_print.h>
|
||||
#include <drm/drm_property.h>
|
||||
|
||||
#include "drm_crtc_internal.h"
|
||||
@ -751,6 +752,64 @@ bool drm_property_replace_blob(struct drm_property_blob **blob,
|
||||
}
|
||||
EXPORT_SYMBOL(drm_property_replace_blob);
|
||||
|
||||
/**
|
||||
* drm_property_replace_blob_from_id - replace a blob property taking a reference
|
||||
* @dev: DRM device
|
||||
* @blob: a pointer to the member blob to be replaced
|
||||
* @blob_id: the id of the new blob to replace with
|
||||
* @expected_size: expected size of the blob property
|
||||
* @expected_elem_size: expected size of an element in the blob property
|
||||
* @replaced: if the blob was in fact replaced
|
||||
*
|
||||
* Look up the new blob from id, take its reference, check expected sizes of
|
||||
* the blob and its element and replace the old blob by the new one. Advertise
|
||||
* if the replacement operation was successful.
|
||||
*
|
||||
* Return: true if the blob was in fact replaced. -EINVAL if the new blob was
|
||||
* not found or sizes don't match.
|
||||
*/
|
||||
int drm_property_replace_blob_from_id(struct drm_device *dev,
|
||||
struct drm_property_blob **blob,
|
||||
uint64_t blob_id,
|
||||
ssize_t expected_size,
|
||||
ssize_t expected_elem_size,
|
||||
bool *replaced)
|
||||
{
|
||||
struct drm_property_blob *new_blob = NULL;
|
||||
|
||||
if (blob_id != 0) {
|
||||
new_blob = drm_property_lookup_blob(dev, blob_id);
|
||||
if (new_blob == NULL) {
|
||||
drm_dbg_atomic(dev,
|
||||
"cannot find blob ID %llu\n", blob_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (expected_size > 0 &&
|
||||
new_blob->length != expected_size) {
|
||||
drm_dbg_atomic(dev,
|
||||
"[BLOB:%d] length %zu different from expected %zu\n",
|
||||
new_blob->base.id, new_blob->length, expected_size);
|
||||
drm_property_blob_put(new_blob);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (expected_elem_size > 0 &&
|
||||
new_blob->length % expected_elem_size != 0) {
|
||||
drm_dbg_atomic(dev,
|
||||
"[BLOB:%d] length %zu not divisible by element size %zu\n",
|
||||
new_blob->base.id, new_blob->length, expected_elem_size);
|
||||
drm_property_blob_put(new_blob);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
*replaced |= drm_property_replace_blob(blob, new_blob);
|
||||
drm_property_blob_put(new_blob);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_property_replace_blob_from_id);
|
||||
|
||||
int drm_mode_getblob_ioctl(struct drm_device *dev,
|
||||
void *data, struct drm_file *file_priv)
|
||||
{
|
||||
|
@ -279,6 +279,12 @@ struct drm_property_blob *drm_property_create_blob(struct drm_device *dev,
|
||||
const void *data);
|
||||
struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev,
|
||||
uint32_t id);
|
||||
int drm_property_replace_blob_from_id(struct drm_device *dev,
|
||||
struct drm_property_blob **blob,
|
||||
uint64_t blob_id,
|
||||
ssize_t expected_size,
|
||||
ssize_t expected_elem_size,
|
||||
bool *replaced);
|
||||
int drm_property_replace_global_blob(struct drm_device *dev,
|
||||
struct drm_property_blob **replace,
|
||||
size_t length,
|
||||
|
Loading…
Reference in New Issue
Block a user