summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPer Persson <per.xb.persson@stericsson.com>2011-06-08 14:32:46 +0200
committerRobert FEKETE <robert.fekete@stericsson.com>2011-06-21 15:03:18 +0200
commit23362b8dfcd202b097c48753f6167b428818ca53 (patch)
tree91fadbde299da89a36801861456df4759e24342c /src
parentf9d5e205cc3af57a38be8e3dd9f4b1c1ad21f099 (diff)
HDMIservice: Allow dynamic minor number
Support is added for that the hdmi display device can have different device minor numbers. ST-Ericsson ID: 344334 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10177 Signed-off-by: Per Persson <per.xb.persson@stericsson.com> Change-Id: I1ba92f35528518c9a9e2c805973dac8033a17f39 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/24689 Reviewed-by: QATOOLS Reviewed-by: QATEST Reviewed-by: Marcel TUNNISSEN <marcel.tuennissen@stericsson.com> Reviewed-by: Per-Daniel OLSSON <per-daniel.olsson@stericsson.com> Reviewed-by: Robert FEKETE <robert.fekete@stericsson.com>
Diffstat (limited to 'src')
-rw-r--r--src/hdmi_service.c64
-rw-r--r--src/setres.c6
2 files changed, 62 insertions, 8 deletions
diff --git a/src/hdmi_service.c b/src/hdmi_service.c
index e262f8b..6232b75 100644
--- a/src/hdmi_service.c
+++ b/src/hdmi_service.c
@@ -20,6 +20,7 @@
#include "linux/fb.h"
#include <sys/socket.h>
#include <utils/Log.h>
+#include <dirent.h>
#include "../include/hdmi_service_api.h"
#include "../include/hdmi_service_local.h"
@@ -38,12 +39,65 @@ enum hdmi_fb_state hdmi_fb_state;
enum hdmi_plug_state hdmi_plug_state = HDMI_PLUGUNDEF;
struct cmd_data *cmd_data;
int cmd_id_ind;
+char dispdevice_path[64];
const __u8 plugdetdis_val[] = {0x00, 0x00, 0x00};/* 00: disable, 00:ontime,
00: offtime*/
const __u8 plugdeten_val[] = {0x01, 0x05, 0x02};/* 01: enable, 05:ontime,
02: offtime*/
+static int hdmidirsort(const struct dirent **a, const struct dirent **b)
+{
+ return 1;
+}
+
+/* Find the correct device path since the device minor number can vary */
+static int dispdevice_path_set(void)
+{
+ struct dirent **namelist;
+ int n;
+ int found = 0;
+
+ n = scandir(DISPDEVICE_PATH_1, &namelist, 0, hdmidirsort);
+ if (n < 0) {
+ LOGHDMILIB("scandir error");
+ return -1;
+ }
+
+ while (n--) {
+ if (!found && strncmp(namelist[n]->d_name, DISPDEVICE_PATH_2,
+ strlen(DISPDEVICE_PATH_2)) == 0) {
+ strcpy(dispdevice_path, namelist[n]->d_name);
+ LOGHDMILIB("%s found:%s\n", __func__, dispdevice_path);
+ found = 1;
+ }
+ free(namelist[n]);
+ }
+ free(namelist);
+ return 0;
+}
+
+static char *dispdevice_path_get(void)
+{
+ return &dispdevice_path[0];
+}
+
+int dispdevice_file_open(char *file, int attr)
+{
+ int fd = -1;
+ char fname[128];
+
+ if (dispdevice_path[0] == 0)
+ dispdevice_path_set();
+
+ if (dispdevice_path[0] != 0) {
+ sprintf(fname, "%s%s/%s", DISPDEVICE_PATH_1,
+ dispdevice_path_get(), file);
+ fd = open(fname, attr);
+ }
+ return fd;
+}
+
int get_new_cmd_id_ind(void)
{
cmd_id_ind++;
@@ -159,7 +213,7 @@ static int hdmi_format_set(enum hdmi_format format)
{
int fd;
- fd = open(HDMIFORMAT_FILE, O_WRONLY);
+ fd = dispdevice_file_open(HDMIFORMAT_FILE, O_WRONLY);
if (fd < 0) {
LOGHDMILIB(" failed to open %s", HDMIFORMAT_FILE);
return -1;
@@ -220,10 +274,10 @@ static int stayalive(__u8 enable)
int cnt = 0;
int res;
- stayalivefd = open(STAYALIVE_FILE, O_WRONLY);
+ stayalivefd = dispdevice_file_open(STAYALIVE_FILE, O_WRONLY);
while ((stayalivefd < 0) && (cnt++ < 30)) {
usleep(200000);
- stayalivefd = open(STAYALIVE_FILE, O_WRONLY);
+ stayalivefd = dispdevice_file_open(STAYALIVE_FILE, O_WRONLY);
}
LOGHDMILIB("cnt:%d", cnt);
@@ -341,7 +395,7 @@ static int hdmiplugged_handle(int *basic_audio_support)
/* Check if fb is created */
/* Get fb dev name */
- disponoff = open(DISPONOFF_FILE, O_RDWR);
+ disponoff = dispdevice_file_open(DISPONOFF_FILE, O_RDWR);
if (disponoff < 0) {
LOGHDMILIB("***** Failed to open %s *****", DISPONOFF_FILE);
ret = -3;
@@ -423,7 +477,7 @@ static int hdmi_fb_close(void)
}
/* Destroy frame buffer */
- disponoff = open(DISPONOFF_FILE, O_WRONLY);
+ disponoff = dispdevice_file_open(DISPONOFF_FILE, O_WRONLY);
if (disponoff < 0) {
LOGHDMILIB("***** Failed to open %s *****", DISPONOFF_FILE);
} else {
diff --git a/src/setres.c b/src/setres.c
index 4e13c6e..a4be32f 100644
--- a/src/setres.c
+++ b/src/setres.c
@@ -63,7 +63,7 @@ int video_formats_supported_hw(void)
char buf[FORMATS_MAX * 2 + 1];
/* Get hw supported formats */
- vesacea = open(VESACEAFORMATS_FILE, O_RDONLY);
+ vesacea = dispdevice_file_open(VESACEAFORMATS_FILE, O_RDONLY);
if (vesacea < 0) {
LOGHDMILIB("***** Failed to open %s *****",
VESACEAFORMATS_FILE);
@@ -116,7 +116,7 @@ static int vesaceanrtovar(struct fb_var_screeninfo *var, __u8 cea,
int interlaced;
/* Request timing info */
- timing = open(TIMING_FILE, O_RDWR);
+ timing = dispdevice_file_open(TIMING_FILE, O_RDWR);
if (timing < 0) {
LOGHDMILIB("***** Failed to open %s *****", TIMING_FILE);
return -1;
@@ -321,7 +321,7 @@ int hdmi_fb_chres(__u8 cea, __u8 vesaceanr)
__u8 num_buffers;
/* Get fb dev name */
- disponoff = open(DISPONOFF_FILE, O_RDONLY);
+ disponoff = dispdevice_file_open(DISPONOFF_FILE, O_RDONLY);
if (disponoff < 0) {
LOGHDMILIB("***** Failed to open %s *****", DISPONOFF_FILE);
return -1;