1 #if defined(CONFIG_MTK_HDMI_SUPPORT)
2 #include <linux/string.h>
3 #include <linux/time.h>
4 #include <linux/uaccess.h>
6 #include <linux/debugfs.h>
8 #include <mach/mt_typedefs.h>
11 #if defined(CONFIG_MTK_INTERNAL_HDMI_SUPPORT)
12 #include "internal_hdmi_drv.h"
13 #elif defined(MTK_INTERNAL_MHL_SUPPORT)
14 #include "inter_mhl_drv.h"
19 //#include "hdmitx_drv.h"
21 #if defined(MTK_INTERNAL_MHL_SUPPORT)
26 void DBG_Deinit(void);
28 extern void hdmi_log_enable(int enable
);
29 extern void hdmi_cable_fake_plug_in(void);
30 extern void hdmi_cable_fake_plug_out(void);
31 extern void hdmi_mmp_enable(int enable
);
32 extern void hdmi_pattern(int enable
);
35 // ---------------------------------------------------------------------------
36 // External variable declarations
37 // ---------------------------------------------------------------------------
39 //extern LCM_DRIVER *lcm_drv;
40 // ---------------------------------------------------------------------------
42 // ---------------------------------------------------------------------------
45 static char STR_HELP
[] =
48 " echo [ACTION]... > hdmi\n"
52 " enable hdmi video output\n"
55 extern void hdmi_log_enable(int enable
);
56 extern void init_hdmi_mmp_events(void);
58 // TODO: this is a temp debug solution
59 //extern void hdmi_cable_fake_plug_in(void);
60 //extern int hdmi_drv_init(void);
61 static void process_dbg_opt(const char *opt
)
68 #if defined(MTK_HDMI_SUPPORT)
69 else if (0 == strncmp(opt
, "on", 2))
73 else if (0 == strncmp(opt
, "off", 3))
77 else if (0 == strncmp(opt
, "suspend", 7))
81 else if (0 == strncmp(opt
, "resume", 6))
85 else if (0 == strncmp(opt
, "colorbar", 8))
89 else if (0 == strncmp(opt
, "ldooff", 6))
93 else if (0 == strncmp(opt
, "log:", 4))
95 if (0 == strncmp(opt
+ 4, "on", 2))
97 hdmi_log_enable(true);
99 else if (0 == strncmp(opt
+ 4, "off", 3))
101 hdmi_log_enable(false);
108 else if (0 == strncmp(opt
, "fakecablein:", 12))
110 if (0 == strncmp(opt
+ 12, "enable", 6))
112 hdmi_cable_fake_plug_in();
114 else if (0 == strncmp(opt
+ 12, "disable", 7))
116 hdmi_cable_fake_plug_out();
123 #if defined(MTK_INTERNAL_MHL_SUPPORT)
124 else if((0 == strncmp(opt
, "dbgtype:", 8))||
125 (0 == strncmp(opt
, "w:", 2))||
126 (0 == strncmp(opt
, "r:", 2))||
127 (0 == strncmp(opt
, "w6:", 3))||
128 (0 == strncmp(opt
, "r6:", 3))||
129 (0 == strncmp(opt
, "hdcp:", 5))||
130 (0 == strncmp(opt
, "status", 6))||
131 (0 == strncmp(opt
, "help", 4))||
132 (0 == strncmp(opt
, "res:", 4))||
133 (0 == strncmp(opt
, "edid", 4)))
135 mt_hdmi_debug_write(opt
);
139 else if (0 == strncmp(opt
, "hdmimmp:", 8))
141 if (0 == strncmp(opt
+ 8, "on", 2))
145 else if (0 == strncmp(opt
+ 8, "init", 4))
147 init_hdmi_mmp_events();
149 else if (0 == strncmp(opt
+ 8, "off", 3))
153 else if (0 == strncmp(opt
+ 8, "img", 3))
162 else if (0 == strncmp(opt
, "hdmi_pattern:", 13))
164 if (0 == strncmp(opt
+ 13, "on", 2))
168 else if (0 == strncmp(opt
+ 13, "off", 3))
172 else if (0 == strncmp(opt
+ 13, "svp", 3))
189 printk("[hdmitx] parse command error!\n\n%s", STR_HELP
);
192 static void process_dbg_cmd(char *cmd
)
196 printk("[hdmitx] %s\n", cmd
);
198 while ((tok
= strsep(&cmd
, " ")) != NULL
)
200 process_dbg_opt(tok
);
204 // ---------------------------------------------------------------------------
205 // Debug FileSystem Routines
206 // ---------------------------------------------------------------------------
208 struct dentry
*hdmitx_dbgfs
= NULL
;
211 static ssize_t
debug_open(struct inode
*inode
, struct file
*file
)
213 file
->private_data
= inode
->i_private
;
218 static char debug_buffer
[2048];
220 static ssize_t
debug_read(struct file
*file
,
221 char __user
*ubuf
, size_t count
, loff_t
*ppos
)
223 const int debug_bufmax
= sizeof(debug_buffer
) - 1;
226 n
+= scnprintf(debug_buffer
+ n
, debug_bufmax
- n
, STR_HELP
);
227 debug_buffer
[n
++] = 0;
229 return simple_read_from_buffer(ubuf
, count
, ppos
, debug_buffer
, n
);
233 static ssize_t
debug_write(struct file
*file
,
234 const char __user
*ubuf
, size_t count
, loff_t
*ppos
)
236 const int debug_bufmax
= sizeof(debug_buffer
) - 1;
241 if (count
> debug_bufmax
)
243 count
= debug_bufmax
;
246 if (copy_from_user(&debug_buffer
, ubuf
, count
))
251 debug_buffer
[count
] = 0;
253 process_dbg_cmd(debug_buffer
);
259 static struct file_operations debug_fops
=
262 .write
= debug_write
,
267 void HDMI_DBG_Init(void)
269 hdmitx_dbgfs
= debugfs_create_file("hdmi",
270 S_IFREG
| S_IRUGO
, NULL
, (void *)0, &debug_fops
);
274 void HDMI_DBG_Deinit(void)
276 debugfs_remove(hdmitx_dbgfs
);