mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
drm/edid: add a helper for EDID sysfs property show
Add a helper to get the EDID property for sysfs property show. This hides all the edid_blob_ptr usage within drm_edid.c. Reviewed-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/902c8e09d25b99391fd9c92d95af07c01d7b7cbd.1715353572.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
parent
42505ab120
commit
adcea136b4
@ -303,6 +303,8 @@ const u8 *drm_edid_find_extension(const struct drm_edid *drm_edid,
|
||||
int ext_id, int *ext_index);
|
||||
void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad);
|
||||
void drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad);
|
||||
ssize_t drm_edid_connector_property_show(struct drm_connector *connector,
|
||||
char *buf, loff_t off, size_t count);
|
||||
|
||||
/* drm_edid_load.c */
|
||||
#ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
|
||||
|
@ -6941,6 +6941,39 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* For sysfs edid show implementation */
|
||||
ssize_t drm_edid_connector_property_show(struct drm_connector *connector,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
const void *edid;
|
||||
size_t size;
|
||||
ssize_t ret = 0;
|
||||
|
||||
mutex_lock(&connector->dev->mode_config.mutex);
|
||||
|
||||
if (!connector->edid_blob_ptr)
|
||||
goto unlock;
|
||||
|
||||
edid = connector->edid_blob_ptr->data;
|
||||
size = connector->edid_blob_ptr->length;
|
||||
if (!edid)
|
||||
goto unlock;
|
||||
|
||||
if (off >= size)
|
||||
goto unlock;
|
||||
|
||||
if (off + count > size)
|
||||
count = size - off;
|
||||
|
||||
memcpy(buf, edid + off, count);
|
||||
|
||||
ret = count;
|
||||
unlock:
|
||||
mutex_unlock(&connector->dev->mode_config.mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* drm_edid_connector_update - Update connector information from EDID
|
||||
* @connector: Connector
|
||||
|
@ -266,29 +266,9 @@ static ssize_t edid_show(struct file *filp, struct kobject *kobj,
|
||||
{
|
||||
struct device *connector_dev = kobj_to_dev(kobj);
|
||||
struct drm_connector *connector = to_drm_connector(connector_dev);
|
||||
unsigned char *edid;
|
||||
size_t size;
|
||||
ssize_t ret = 0;
|
||||
ssize_t ret;
|
||||
|
||||
mutex_lock(&connector->dev->mode_config.mutex);
|
||||
if (!connector->edid_blob_ptr)
|
||||
goto unlock;
|
||||
|
||||
edid = connector->edid_blob_ptr->data;
|
||||
size = connector->edid_blob_ptr->length;
|
||||
if (!edid)
|
||||
goto unlock;
|
||||
|
||||
if (off >= size)
|
||||
goto unlock;
|
||||
|
||||
if (off + count > size)
|
||||
count = size - off;
|
||||
memcpy(buf, edid + off, count);
|
||||
|
||||
ret = count;
|
||||
unlock:
|
||||
mutex_unlock(&connector->dev->mode_config.mutex);
|
||||
ret = drm_edid_connector_property_show(connector, buf, off, count);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user