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);
78 hdmi->autoconfig = HDMI_DISABLE;
79 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)
114 if(direction == DISPLAY_SCALE_X)
115 hdmi->xscale = value;
116 else if(direction == DISPLAY_SCALE_Y)
117 hdmi->yscale = value;
120 rk_fb_disp_scale(hdmi->xscale, hdmi->yscale, hdmi->lcdc->id);
124 static int hdmi_get_scale(struct rk_display_device *device, int direction)
126 struct hdmi *hdmi = device->priv_data;
131 if(direction == DISPLAY_SCALE_X)
133 else if(direction == DISPLAY_SCALE_Y)
139 struct rk_display_ops hdmi_display_ops = {
140 .setenable = hdmi_set_enable,
141 .getenable = hdmi_get_enable,
142 .getstatus = hdmi_get_status,
143 .getmodelist = hdmi_get_modelist,
144 .setmode = hdmi_set_mode,
145 .getmode = hdmi_get_mode,
146 .setscale = hdmi_set_scale,
147 .getscale = hdmi_get_scale,
151 static int hdmi_display_probe(struct rk_display_device *device, void *devdata)
153 device->owner = THIS_MODULE;
154 strcpy(device->type, "HDMI");
155 device->priority = DISPLAY_PRIORITY_HDMI;
156 // device->name = kmalloc(strlen(name), GFP_KERNEL);
159 // strcpy(device->name, name);
161 device->priv_data = devdata;
162 device->ops = &hdmi_display_ops;
166 static struct rk_display_driver display_hdmi = {
167 .probe = hdmi_display_probe,
170 static struct rk_display_device *display_device_hdmi = NULL;
172 void hdmi_register_display_sysfs(struct hdmi *hdmi, struct device *parent)
174 display_device_hdmi = rk_display_device_register(&display_hdmi, parent, hdmi);
177 void hdmi_unregister_display_sysfs(struct hdmi *hdmi)
179 if(display_device_hdmi)
180 rk_display_device_unregister(display_device_hdmi);