All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] acpi: Export EDID blocks to the kernel
@ 2010-01-12 19:17 Matthew Garrett
  2010-03-30 16:49 ` Matthew Garrett
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Garrett @ 2010-01-12 19:17 UTC (permalink / raw)
  To: linux-acpi; +Cc: lenb, dri-devel, Matthew Garrett

The ACPI spec includes a provision for hardware to provide EDID via the
ACPI video extension. In the KMS world it's necessary for a way to obtain
this from within the kernel. Add a function that either returns the EDID
for the provided ACPI display ID or the first display of the provided type.
Also add support for ensuring that devices with legacy IDs are supported.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
 drivers/acpi/video.c |  110 ++++++++++++++++++++++++++++++++++++++++++++++----
 include/acpi/video.h |   16 +++++++
 2 files changed, 118 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 72e76b4..1868b3a 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -43,6 +43,7 @@
 #include <linux/dmi.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
+#include <acpi/video.h>
 
 #define PREFIX "ACPI: "
 
@@ -63,11 +64,6 @@
 
 #define MAX_NAME_LEN	20
 
-#define ACPI_VIDEO_DISPLAY_CRT	1
-#define ACPI_VIDEO_DISPLAY_TV	2
-#define ACPI_VIDEO_DISPLAY_DVI	3
-#define ACPI_VIDEO_DISPLAY_LCD	4
-
 #define _COMPONENT		ACPI_VIDEO_COMPONENT
 ACPI_MODULE_NAME("video");
 
@@ -1724,11 +1720,27 @@ acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id
 }
 
 static int
+acpi_video_get_device_type(struct acpi_video_bus *video,
+			   unsigned long device_id)
+{
+	struct acpi_video_enumerated_device *ids;
+	int i;
+
+	for (i = 0; i < video->attached_count; i++) {
+		ids = &video->attached_array[i];
+		if ((ids->value.int_val & 0xffff) == device_id)
+			return ids->value.int_val;
+	}
+
+	return 0;
+}
+
+static int
 acpi_video_bus_get_one_device(struct acpi_device *device,
 			      struct acpi_video_bus *video)
 {
 	unsigned long long device_id;
-	int status;
+	int status, device_type;
 	struct acpi_video_device *data;
 	struct acpi_video_device_attrib* attribute;
 
@@ -1773,8 +1785,25 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
 			}
 			if(attribute->bios_can_detect)
 				data->flags.bios = 1;
-		} else
-			data->flags.unknown = 1;
+		} else {
+			/* Check for legacy IDs */
+			device_type = acpi_video_get_device_type(video,
+								 device_id);
+			/* Ignore bits 16 and 18-20 */
+			switch (device_type & 0xffe2ffff) {
+			case ACPI_VIDEO_DISPLAY_LEGACY_MONITOR:
+				data->flags.crt = 1;
+				break;
+			case ACPI_VIDEO_DISPLAY_LEGACY_PANEL:
+				data->flags.lcd = 1;
+				break;
+			case ACPI_VIDEO_DISPLAY_LEGACY_TV:
+				data->flags.tvout = 1;
+				break;
+			default:
+				data->flags.unknown = 1;
+			}
+		}
 
 		acpi_video_device_bind(video, data);
 		acpi_video_device_find_cap(data);
@@ -2008,6 +2037,71 @@ out:
 	return result;
 }
 
+int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
+			void **edid)
+{
+	struct acpi_video_bus *video;
+	struct acpi_video_device *video_device;
+	union acpi_object *buffer = NULL;
+	acpi_status status;
+	int i, length;
+
+	if (!device || !acpi_driver_data(device))
+		return -EINVAL;
+
+	video = acpi_driver_data(device);
+
+	for (i = 0; i < video->attached_count; i++) {
+		video_device = video->attached_array[i].bind_info;
+		length = 256;
+
+		if (!video_device)
+			continue;
+
+		if (type) {
+			switch (type) {
+			case ACPI_VIDEO_DISPLAY_CRT:
+				if (!video_device->flags.crt)
+					continue;
+				break;
+			case ACPI_VIDEO_DISPLAY_TV:
+				if (!video_device->flags.tvout)
+					continue;
+				break;
+			case ACPI_VIDEO_DISPLAY_DVI:
+				if (!video_device->flags.dvi)
+					continue;
+				break;
+			case ACPI_VIDEO_DISPLAY_LCD:
+				if (!video_device->flags.lcd)
+					continue;
+				break;
+			}
+		} else if (video_device->device_id != device_id) {
+			continue;
+		}
+
+		status = acpi_video_device_EDID(video_device, &buffer, length);
+
+		if (ACPI_FAILURE(status) || !buffer ||
+		    buffer->type != ACPI_TYPE_BUFFER) {
+			length = 128;
+			status = acpi_video_device_EDID(video_device, &buffer,
+							length);
+			if (ACPI_FAILURE(status) || !buffer ||
+			    buffer->type != ACPI_TYPE_BUFFER) {
+				continue;
+			}
+		}
+
+		*edid = buffer->buffer.pointer;
+		return length;
+	}
+
+	return -ENODEV;
+}
+EXPORT_SYMBOL(acpi_video_get_edid);
+
 static int
 acpi_video_bus_get_devices(struct acpi_video_bus *video,
 			   struct acpi_device *device)
diff --git a/include/acpi/video.h b/include/acpi/video.h
index cf7be3d..551793c 100644
--- a/include/acpi/video.h
+++ b/include/acpi/video.h
@@ -1,12 +1,28 @@
 #ifndef __ACPI_VIDEO_H
 #define __ACPI_VIDEO_H
 
+#define ACPI_VIDEO_DISPLAY_CRT  1
+#define ACPI_VIDEO_DISPLAY_TV   2
+#define ACPI_VIDEO_DISPLAY_DVI  3
+#define ACPI_VIDEO_DISPLAY_LCD  4
+
+#define ACPI_VIDEO_DISPLAY_LEGACY_MONITOR 0x0100
+#define ACPI_VIDEO_DISPLAY_LEGACY_PANEL   0x0110
+#define ACPI_VIDEO_DISPLAY_LEGACY_TV      0x0200
+
 #if (defined CONFIG_ACPI_VIDEO || defined CONFIG_ACPI_VIDEO_MODULE)
 extern int acpi_video_register(void);
 extern void acpi_video_unregister(void);
+extern int acpi_video_get_edid(struct acpi_device *device, int type,
+			       int device_id, void **edid);
 #else
 static inline int acpi_video_register(void) { return 0; }
 static inline void acpi_video_unregister(void) { return; }
+static inline int acpi_video_get_edid(struct acpi_device *device, int type,
+				      int device_id, void **edid)
+{
+	return -ENODEV;
+}
 #endif
 
 #endif
-- 
1.6.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] acpi: Export EDID blocks to the kernel
  2010-01-12 19:17 [PATCH] acpi: Export EDID blocks to the kernel Matthew Garrett
@ 2010-03-30 16:49 ` Matthew Garrett
  2010-04-01  0:53   ` Len Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Garrett @ 2010-03-30 16:49 UTC (permalink / raw)
  To: linux-acpi; +Cc: lenb

On Tue, Jan 12, 2010 at 02:17:03PM -0500, Matthew Garrett wrote:
> The ACPI spec includes a provision for hardware to provide EDID via the
> ACPI video extension. In the KMS world it's necessary for a way to obtain
> this from within the kernel. Add a function that either returns the EDID
> for the provided ACPI display ID or the first display of the provided type.
> Also add support for ensuring that devices with legacy IDs are supported.
> 
> Signed-off-by: Matthew Garrett <mjg@redhat.com>

Did this get picked up?

-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] acpi: Export EDID blocks to the kernel
  2010-03-30 16:49 ` Matthew Garrett
@ 2010-04-01  0:53   ` Len Brown
  2010-04-02  3:19     ` Zhang Rui
  0 siblings, 1 reply; 4+ messages in thread
From: Len Brown @ 2010-04-01  0:53 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: linux-acpi


On Tue, 30 Mar 2010, Matthew Garrett wrote:

> On Tue, Jan 12, 2010 at 02:17:03PM -0500, Matthew Garrett wrote:
> > The ACPI spec includes a provision for hardware to provide EDID via the
> > ACPI video extension. In the KMS world it's necessary for a way to obtain
> > this from within the kernel. Add a function that either returns the EDID
> > for the provided ACPI display ID or the first display of the provided type.
> > Also add support for ensuring that devices with legacy IDs are supported.
> > 
> > Signed-off-by: Matthew Garrett <mjg@redhat.com>
> 
> Did this get picked up?


No, it did not.

Rui,
Matthew is proposing adding an API to your driver.

-Len


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] acpi: Export EDID blocks to the kernel
  2010-04-01  0:53   ` Len Brown
@ 2010-04-02  3:19     ` Zhang Rui
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang Rui @ 2010-04-02  3:19 UTC (permalink / raw)
  To: Len Brown; +Cc: Matthew Garrett, linux-acpi

On Thu, 2010-04-01 at 08:53 +0800, Len Brown wrote:
> On Tue, 30 Mar 2010, Matthew Garrett wrote:
> 
> > On Tue, Jan 12, 2010 at 02:17:03PM -0500, Matthew Garrett wrote:
> > > The ACPI spec includes a provision for hardware to provide EDID via the
> > > ACPI video extension. In the KMS world it's necessary for a way to obtain
> > > this from within the kernel. Add a function that either returns the EDID
> > > for the provided ACPI display ID or the first display of the provided type.
> > > Also add support for ensuring that devices with legacy IDs are supported.
> > > 
> > > Signed-off-by: Matthew Garrett <mjg@redhat.com>
> > 
> > Did this get picked up?
> 
> 
> No, it did not.
> 
> Rui,
> Matthew is proposing adding an API to your driver.
> 

Acked-by: Zhang Rui <rui.zhang@intel.com>

> -Len
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-02  3:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-12 19:17 [PATCH] acpi: Export EDID blocks to the kernel Matthew Garrett
2010-03-30 16:49 ` Matthew Garrett
2010-04-01  0:53   ` Len Brown
2010-04-02  3:19     ` Zhang Rui

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.