summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisael Lopez Cruz2013-08-02 16:29:00 -0500
committerMisael Lopez Cruz2013-10-22 23:47:11 -0500
commit050dd03d3f3128433ec2a9f023a7085c6a9dc16c (patch)
tree5f99da33b8b1b14da7be6cb644c9719eafb81944
parentc98083eb0536df412c1cd4e83301032052afeaa8 (diff)
downloaddevice-ti-common-open-050dd03d3f3128433ec2a9f023a7085c6a9dc16c.tar.gz
device-ti-common-open-050dd03d3f3128433ec2a9f023a7085c6a9dc16c.tar.xz
device-ti-common-open-050dd03d3f3128433ec2a9f023a7085c6a9dc16c.zip
audio: hdmi: Find HDMI display dynamically
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>
-rw-r--r--audio/hdmi_audio_hal.h2
-rw-r--r--audio/hdmi_audio_hw.c4
-rw-r--r--audio/hdmi_audio_utils.c55
3 files changed, 49 insertions, 12 deletions
diff --git a/audio/hdmi_audio_hal.h b/audio/hdmi_audio_hal.h
index 8d5063a..545e50e 100644
--- a/audio/hdmi_audio_hal.h
+++ b/audio/hdmi_audio_hal.h
@@ -32,6 +32,6 @@ typedef struct _hdmi_audio_caps {
32#define CEA_SPKR_RLCRRC (1 << 6) 32#define CEA_SPKR_RLCRRC (1 << 6)
33 33
34/* Defined in file hdmi_audio_utils.c */ 34/* Defined in file hdmi_audio_utils.c */
35int hdmi_query_audio_caps(const char* edid_path, hdmi_audio_caps_t *caps); 35int hdmi_query_audio_caps(hdmi_audio_caps_t *caps);
36 36
37#endif /* TI_HDMI_AUDIO_HAL */ 37#endif /* TI_HDMI_AUDIO_HAL */
diff --git a/audio/hdmi_audio_hw.c b/audio/hdmi_audio_hw.c
index 4085e97..afde5ac 100644
--- a/audio/hdmi_audio_hw.c
+++ b/audio/hdmi_audio_hw.c
@@ -62,8 +62,6 @@
62#define HDMI_PERIOD_COUNT 4 62#define HDMI_PERIOD_COUNT 4
63#define HDMI_MAX_CHANNELS 8 63#define HDMI_MAX_CHANNELS 8
64 64
65#define HDMI_EDID_PATH "/sys/devices/omapdss/display1/edid"
66
67typedef audio_hw_device_t hdmi_device_t; 65typedef audio_hw_device_t hdmi_device_t;
68 66
69struct hdmi_device_t { 67struct hdmi_device_t {
@@ -206,7 +204,7 @@ char * hdmi_out_get_parameters(const struct audio_stream *stream,
206 204
207 TRACEM("stream=%p keys='%s'", stream, keys); 205 TRACEM("stream=%p keys='%s'", stream, keys);
208 206
209 if (hdmi_query_audio_caps(HDMI_EDID_PATH, &caps)) { 207 if (hdmi_query_audio_caps(&caps)) {
210 ALOGE("Unable to get the HDMI audio capabilities"); 208 ALOGE("Unable to get the HDMI audio capabilities");
211 str = calloc(1, 1); 209 str = calloc(1, 1);
212 goto end; 210 goto end;
diff --git a/audio/hdmi_audio_utils.c b/audio/hdmi_audio_utils.c
index e781351..a436988 100644
--- a/audio/hdmi_audio_utils.c
+++ b/audio/hdmi_audio_utils.c
@@ -72,6 +72,11 @@
72 ***************************************************************** 72 *****************************************************************
73 */ 73 */
74 74
75#define DISPLAY_MAX 3
76#define DISPLAY_NAME_MAX 20
77#define HDMI_DISPLAY_NAME "hdmi"
78#define OMAP_DSS_SYSFS "/sys/devices/platform/omapdss/"
79
75/* TODO: Figure this out dynamically, but ATM this is enforced 80/* TODO: Figure this out dynamically, but ATM this is enforced
76 * in the kernel. 81 * in the kernel.
77 */ 82 */
@@ -143,9 +148,11 @@ static void hdmi_dump_short_audio_descriptor_block(unsigned char *mem)
143 } 148 }
144} 149}
145 150
146int hdmi_query_audio_caps(const char* edid_path, hdmi_audio_caps_t *caps) 151int hdmi_query_audio_caps(hdmi_audio_caps_t *caps)
147{ 152{
148 int fd; 153 int fd;
154 char fn[256];
155 char disp_name[DISPLAY_NAME_MAX];
149 unsigned char edid[HDMI_MAX_EDID]; 156 unsigned char edid[HDMI_MAX_EDID];
150 int status; 157 int status;
151 int index, n; 158 int index, n;
@@ -156,9 +163,44 @@ int hdmi_query_audio_caps(const char* edid_path, hdmi_audio_caps_t *caps)
156 int speaker_alloc = 0; 163 int speaker_alloc = 0;
157 int done = 0; 164 int done = 0;
158 165
166 for (index = 0; index < DISPLAY_MAX; index++) {
167 snprintf(fn, sizeof(fn), OMAP_DSS_SYSFS "display%u", index);
168 fd = open(fn, O_RDONLY);
169 if (fd < 0) {
170 ALOGE("HDMI device not found");
171 return -ENODEV;
172 }
173 close(fd);
174
175 snprintf(fn, sizeof(fn), OMAP_DSS_SYSFS "display%u/name", index);
176 fd = open(fn, O_RDONLY);
177 if (fd < 0) {
178 ALOGE("Error opening display name");
179 return -ENODEV;
180 }
181
182 status = read(fd, disp_name, sizeof(disp_name));
183 close(fd);
184 if (status == -1) {
185 ALOGE("Error reading display name");
186 return -errno;
187 }
188
189 if (!strncasecmp(disp_name, HDMI_DISPLAY_NAME, strlen(HDMI_DISPLAY_NAME))) {
190 ALOGV("HDMI device found at display%u", index);
191 break;
192 }
193 }
194
195 if (index == DISPLAY_MAX) {
196 ALOGE("HDMI device not found");
197 return -ENODEV;
198 }
199
159 memset(edid, 0, sizeof(edid)); 200 memset(edid, 0, sizeof(edid));
160 201
161 fd = open(edid_path, O_RDONLY); 202 snprintf(fn, sizeof(fn), OMAP_DSS_SYSFS "display%u/edid", index);
203 fd = open(fn, O_RDONLY);
162 if (fd == -1) { 204 if (fd == -1) {
163 return -errno; 205 return -errno;
164 } 206 }
@@ -237,19 +279,16 @@ int hdmi_query_audio_caps(const char* edid_path, hdmi_audio_caps_t *caps)
237int main(int argc, char* argv[]) 279int main(int argc, char* argv[])
238{ 280{
239 const char prog_name[] = "hdmi_audio_caps"; 281 const char prog_name[] = "hdmi_audio_caps";
240 const char *edid_path;
241 hdmi_audio_caps_t caps = { 282 hdmi_audio_caps_t caps = {
242 .has_audio = 0, 283 .has_audio = 0,
243 }; 284 };
244 285
245 if (argc < 2) { 286 if (argc < 1) {
246 printf("usage: %s <edid-file>\n", argc ? argv[0] : prog_name); 287 printf("usage: %s\n", argc ? argv[0] : prog_name);
247 return 0; 288 return 0;
248 } 289 }
249 290
250 edid_path = argv[1]; 291 if (hdmi_query_audio_caps(&caps)) {
251
252 if (hdmi_query_audio_caps(edid_path, &caps)) {
253 fprintf(stderr, "Fatal error: could not read EDID (%s)\n", 292 fprintf(stderr, "Fatal error: could not read EDID (%s)\n",
254 strerror(errno)); 293 strerror(errno));
255 return 1; 294 return 1;