1 #include <linux/ctype.h>
2 #include <linux/string.h>
3 #include <linux/display-sys.h>
4 #include <linux/interrupt.h>
7 static int hdmi_get_enable(struct rk_display_device *device)
9 struct hdmi *hdmi = device->priv_data;
12 mutex_lock(&hdmi->enable_mutex);
13 enable = hdmi->enable;
14 mutex_unlock(&hdmi->enable_mutex);
19 static int hdmi_set_enable(struct rk_display_device *device, int enable)
21 struct hdmi *hdmi = device->priv_data;
23 mutex_lock(&hdmi->enable_mutex);
24 if(hdmi->enable == enable) {
25 mutex_unlock(&hdmi->enable_mutex);
28 hdmi->enable = enable;
31 mutex_unlock(&hdmi->enable_mutex);
37 disable_irq(hdmi->irq);
38 mutex_unlock(&hdmi->enable_mutex);
39 hdmi->command = HDMI_CONFIG_ENABLE;
40 queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, 0);
44 enable_irq(hdmi->irq);
45 #if defined(CONFIG_HDMI_RK610) || defined(CONFIG_HDMI_RK2928)
46 queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, 0);
48 mutex_unlock(&hdmi->enable_mutex);
53 static int hdmi_get_status(struct rk_display_device *device)
55 struct hdmi *hdmi = device->priv_data;
56 if(hdmi->hotplug == HDMI_HPD_ACTIVED)
62 static int hdmi_get_modelist(struct rk_display_device *device, struct list_head **modelist)
64 struct hdmi *hdmi = device->priv_data;
67 *modelist = &hdmi->edid.modelist;
71 static int hdmi_set_mode(struct rk_display_device *device, struct fb_videomode *mode)
73 struct hdmi *hdmi = device->priv_data;
74 int vic = hdmi_videomode_to_vic(mode);
76 hdmi->autoconfig = HDMI_DISABLE;
77 if(vic && hdmi->vic != vic)
82 hdmi->command = HDMI_CONFIG_VIDEO;
83 init_completion(&hdmi->complete);
85 queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, 0);
86 wait_for_completion_interruptible_timeout(&hdmi->complete,
87 msecs_to_jiffies(10000));
92 static int hdmi_get_mode(struct rk_display_device *device, struct fb_videomode *mode)
94 struct hdmi *hdmi = device->priv_data;
95 struct fb_videomode *vmode;
100 vmode = (struct fb_videomode*) hdmi_vic_to_videomode(hdmi->vic);
101 if(unlikely(vmode == NULL))
107 static int hdmi_set_scale(struct rk_display_device *device, int direction, int value)
109 struct hdmi *hdmi = device->priv_data;
111 if(!hdmi || value < 0 || value > 100)
117 if(direction == DISPLAY_SCALE_X)
118 hdmi->xscale = value;
119 else if(direction == DISPLAY_SCALE_Y)
120 hdmi->yscale = value;
123 rk_fb_disp_scale(hdmi->xscale, hdmi->yscale, hdmi->lcdc->id);
127 static int hdmi_get_scale(struct rk_display_device *device, int direction)
129 struct hdmi *hdmi = device->priv_data;
134 if(direction == DISPLAY_SCALE_X)
136 else if(direction == DISPLAY_SCALE_Y)
142 struct rk_display_ops hdmi_display_ops = {
143 .setenable = hdmi_set_enable,
144 .getenable = hdmi_get_enable,
145 .getstatus = hdmi_get_status,
146 .getmodelist = hdmi_get_modelist,
147 .setmode = hdmi_set_mode,
148 .getmode = hdmi_get_mode,
149 .setscale = hdmi_set_scale,
150 .getscale = hdmi_get_scale,
154 static int hdmi_display_probe(struct rk_display_device *device, void *devdata)
156 device->owner = THIS_MODULE;
157 strcpy(device->type, "HDMI");
158 device->priority = DISPLAY_PRIORITY_HDMI;
159 // device->name = kmalloc(strlen(name), GFP_KERNEL);
162 // strcpy(device->name, name);
164 device->priv_data = devdata;
165 device->ops = &hdmi_display_ops;
169 static struct rk_display_driver display_hdmi = {
170 .probe = hdmi_display_probe,
173 static struct rk_display_device *display_device_hdmi = NULL;
175 void hdmi_register_display_sysfs(struct hdmi *hdmi, struct device *parent)
177 display_device_hdmi = rk_display_device_register(&display_hdmi, parent, hdmi);
180 void hdmi_unregister_display_sysfs(struct hdmi *hdmi)
182 if(display_device_hdmi)
183 rk_display_device_unregister(display_device_hdmi);