[Intel-gfx] [PATCH V2] drm: export get and put connector type id
Ma Ling
ling.ma at intel.com
Tue May 26 05:20:14 CEST 2009
We use connector type id as sequence to avoid duplicate connector name.
However for some connectors that advertise multiple functions
we have to meet the same issue, i.e. connector advertise two functions-
DVI and VGA, actually only VGA is real one, in init function card0-VGA-1
is allocated for CRT, and card0-DVI-D-1 is allocated for DVI, but until
detection process complete we could be aware of VGA, not DVI for this
connector, then we change constructed connector type as VGA, which cause that
the name card0-VGA-1 would be allocated to both a CRT and that connector.
The patch intends to avoid above case by exporting get and put connectortype id.
Signed-off-by: Ma Ling <ling.ma at intel.com>
---
drivers/gpu/drm/drm_crtc.c | 12 ++++++++++--
drivers/gpu/drm/drm_sysfs.c | 2 ++
include/drm/drm_crtc.h | 3 +++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 94a7688..4d9756a 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -148,6 +148,16 @@ static struct drm_conn_prop_enum_list drm_connector_enum_list[] =
{ DRM_MODE_CONNECTOR_HDMIB, "HDMI Type B", 0 },
};
+int drm_get_connector_type_id(struct drm_connector *connector)
+{
+ return ++drm_connector_enum_list[connector->connector_type].count;
+}
+
+void drm_put_connector_type_id(struct drm_connector *connector)
+{
+ --drm_connector_enum_list[connector->connector_type].count;
+}
+
static struct drm_prop_enum_list drm_encoder_enum_list[] =
{ { DRM_MODE_ENCODER_NONE, "None" },
{ DRM_MODE_ENCODER_DAC, "DAC" },
@@ -451,8 +461,6 @@ void drm_connector_init(struct drm_device *dev,
connector->funcs = funcs;
drm_mode_object_get(dev, &connector->base, DRM_MODE_OBJECT_CONNECTOR);
connector->connector_type = connector_type;
- connector->connector_type_id =
- ++drm_connector_enum_list[connector_type].count; /* TODO */
INIT_LIST_HEAD(&connector->user_modes);
INIT_LIST_HEAD(&connector->probed_modes);
INIT_LIST_HEAD(&connector->modes);
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 8f93729..443a432 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -343,6 +343,7 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
/* We shouldn't get called more than once for the same connector */
BUG_ON(device_is_registered(&connector->kdev));
+ drm_get_connector_type_id(connector);
connector->kdev.parent = &dev->primary->kdev;
connector->kdev.class = drm_class;
connector->kdev.release = drm_sysfs_device_release;
@@ -428,6 +429,7 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
DRM_DEBUG("removing \"%s\" from sysfs\n",
drm_get_connector_name(connector));
+ drm_put_connector_type_id(connector);
for (i = 0; i < ARRAY_SIZE(connector_attrs); i++)
device_remove_file(&connector->kdev, &connector_attrs[i]);
sysfs_remove_bin_file(&connector->kdev.kobj, &edid_attr);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 3c1924c..64ce824 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -733,4 +733,7 @@ extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
extern bool drm_detect_hdmi_monitor(struct edid *edid);
+
+extern int drm_get_connector_type_id(struct drm_connector *connector);
+extern void drm_put_connector_type_id(struct drm_connector *connector);
#endif /* __DRM_CRTC_H__ */
--
1.5.4.4
More information about the Intel-gfx
mailing list