]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/device-ti-common-open.git/commitdiff
audio: hdmi: Find HDMI display dynamically
authorMisael Lopez Cruz <misael.lopez@ti.com>
Fri, 2 Aug 2013 21:29:00 +0000 (16:29 -0500)
committerMisael Lopez Cruz <misael.lopez@ti.com>
Wed, 23 Oct 2013 04:47:11 +0000 (23:47 -0500)
HDMI is not always assigned to display1, so the EDID path changes
accordingly. It's searched dynamically now (first match).

Additionally, the sysfs entry is also replaced to:
  /sys/devices/platform/omapdss/

Previous sysfs entry (/sys/devices/omapdss) is obsolete.

Change-Id: Ib8e4990353cc1eaf9b8e5c9460b74b5e4af6f165
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
audio/hdmi_audio_hal.h
audio/hdmi_audio_hw.c
audio/hdmi_audio_utils.c

index 8d5063a0d41d96d72556eed07a297e8e5a4918d3..545e50eac276368556312e7bb4194c51241d38e4 100644 (file)
@@ -32,6 +32,6 @@ typedef struct _hdmi_audio_caps {
 #define CEA_SPKR_RLCRRC (1 << 6)
 
 /* Defined in file hdmi_audio_utils.c */
-int hdmi_query_audio_caps(const char* edid_path, hdmi_audio_caps_t *caps);
+int hdmi_query_audio_caps(hdmi_audio_caps_t *caps);
 
 #endif /* TI_HDMI_AUDIO_HAL */
index 4085e974b938bdbbbb32f4c6e9ba1c69e2abf58f..afde5ac1cd10aa8a87162807044d240d3a041129 100644 (file)
@@ -62,8 +62,6 @@
 #define HDMI_PERIOD_COUNT 4
 #define HDMI_MAX_CHANNELS 8
 
-#define HDMI_EDID_PATH "/sys/devices/omapdss/display1/edid"
-
 typedef audio_hw_device_t hdmi_device_t;
 
 struct hdmi_device_t {
@@ -206,7 +204,7 @@ char * hdmi_out_get_parameters(const struct audio_stream *stream,
 
     TRACEM("stream=%p keys='%s'", stream, keys);
 
-    if (hdmi_query_audio_caps(HDMI_EDID_PATH, &caps)) {
+    if (hdmi_query_audio_caps(&caps)) {
         ALOGE("Unable to get the HDMI audio capabilities");
         str = calloc(1, 1);
         goto end;
index e7813518de949aa91468924faed311c2a7393de2..a4369885c49d9645c5f398c80480ed996e8dc398 100644 (file)
  *****************************************************************
  */
 
+#define DISPLAY_MAX           3
+#define DISPLAY_NAME_MAX      20
+#define HDMI_DISPLAY_NAME     "hdmi"
+#define OMAP_DSS_SYSFS        "/sys/devices/platform/omapdss/"
+
 /* TODO: Figure this out dynamically, but ATM this is enforced
  * in the kernel.
  */
@@ -143,9 +148,11 @@ static void hdmi_dump_short_audio_descriptor_block(unsigned char *mem)
     }
 }
 
-int hdmi_query_audio_caps(const char* edid_path, hdmi_audio_caps_t *caps)
+int hdmi_query_audio_caps(hdmi_audio_caps_t *caps)
 {
     int fd;
+    char fn[256];
+    char disp_name[DISPLAY_NAME_MAX];
     unsigned char edid[HDMI_MAX_EDID];
     int status;
     int index, n;
@@ -156,9 +163,44 @@ int hdmi_query_audio_caps(const char* edid_path, hdmi_audio_caps_t *caps)
     int speaker_alloc = 0;
     int done = 0;
 
+    for (index = 0; index < DISPLAY_MAX; index++) {
+        snprintf(fn, sizeof(fn), OMAP_DSS_SYSFS "display%u", index);
+        fd = open(fn, O_RDONLY);
+        if (fd < 0) {
+            ALOGE("HDMI device not found");
+            return -ENODEV;
+        }
+        close(fd);
+
+        snprintf(fn, sizeof(fn), OMAP_DSS_SYSFS "display%u/name", index);
+        fd = open(fn, O_RDONLY);
+        if (fd < 0) {
+            ALOGE("Error opening display name");
+            return -ENODEV;
+        }
+
+        status = read(fd, disp_name, sizeof(disp_name));
+        close(fd);
+        if (status == -1) {
+            ALOGE("Error reading display name");
+            return -errno;
+        }
+
+        if (!strncasecmp(disp_name, HDMI_DISPLAY_NAME, strlen(HDMI_DISPLAY_NAME))) {
+            ALOGV("HDMI device found at display%u", index);
+            break;
+        }
+    }
+
+    if (index == DISPLAY_MAX) {
+        ALOGE("HDMI device not found");
+        return -ENODEV;
+    }
+
     memset(edid, 0, sizeof(edid));
 
-    fd = open(edid_path, O_RDONLY);
+    snprintf(fn, sizeof(fn), OMAP_DSS_SYSFS "display%u/edid", index);
+    fd = open(fn, O_RDONLY);
     if (fd == -1) {
         return -errno;
     }
@@ -237,19 +279,16 @@ int hdmi_query_audio_caps(const char* edid_path, hdmi_audio_caps_t *caps)
 int main(int argc, char* argv[])
 {
     const char prog_name[] = "hdmi_audio_caps";
-    const char *edid_path;
     hdmi_audio_caps_t caps = {
         .has_audio = 0,
     };
 
-    if (argc < 2) {
-        printf("usage: %s <edid-file>\n", argc ? argv[0] : prog_name);
+    if (argc < 1) {
+        printf("usage: %s\n", argc ? argv[0] : prog_name);
         return 0;
     }
 
-    edid_path = argv[1];
-
-    if (hdmi_query_audio_caps(edid_path, &caps)) {
+    if (hdmi_query_audio_caps(&caps)) {
         fprintf(stderr, "Fatal error: could not read EDID (%s)\n",
                 strerror(errno));
         return 1;