aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/fsl-diu-fb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/fsl-diu-fb.c')
-rw-r--r--drivers/video/fsl-diu-fb.c74
1 files changed, 55 insertions, 19 deletions
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
index 0acc7d65aeaa..0f1933b54596 100644
--- a/drivers/video/fsl-diu-fb.c
+++ b/drivers/video/fsl-diu-fb.c
@@ -31,8 +31,6 @@
31#include <linux/uaccess.h> 31#include <linux/uaccess.h>
32#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
33 33
34#include <linux/of_platform.h>
35
36#include <sysdev/fsl_soc.h> 34#include <sysdev/fsl_soc.h>
37#include <linux/fsl-diu-fb.h> 35#include <linux/fsl-diu-fb.h>
38#include "edid.h" 36#include "edid.h"
@@ -183,7 +181,8 @@ static struct fb_videomode __devinitdata fsl_diu_mode_db[] = {
183 181
184static char *fb_mode = "1024x768-32@60"; 182static char *fb_mode = "1024x768-32@60";
185static unsigned long default_bpp = 32; 183static unsigned long default_bpp = 32;
186static int monitor_port; 184static enum fsl_diu_monitor_port monitor_port;
185static char *monitor_string;
187 186
188#if defined(CONFIG_NOT_COHERENT_CACHE) 187#if defined(CONFIG_NOT_COHERENT_CACHE)
189static u8 *coherence_data; 188static u8 *coherence_data;
@@ -201,7 +200,7 @@ struct fsl_diu_data {
201 void *dummy_aoi_virt; 200 void *dummy_aoi_virt;
202 unsigned int irq; 201 unsigned int irq;
203 int fb_enabled; 202 int fb_enabled;
204 int monitor_port; 203 enum fsl_diu_monitor_port monitor_port;
205}; 204};
206 205
207struct mfb_info { 206struct mfb_info {
@@ -282,6 +281,37 @@ static struct diu_hw dr = {
282static struct diu_pool pool; 281static struct diu_pool pool;
283 282
284/** 283/**
284 * fsl_diu_name_to_port - convert a port name to a monitor port enum
285 *
286 * Takes the name of a monitor port ("dvi", "lvds", or "dlvds") and returns
287 * the enum fsl_diu_monitor_port that corresponds to that string.
288 *
289 * For compatibility with older versions, a number ("0", "1", or "2") is also
290 * supported.
291 *
292 * If the string is unknown, DVI is assumed.
293 *
294 * If the particular port is not supported by the platform, another port
295 * (platform-specific) is chosen instead.
296 */
297static enum fsl_diu_monitor_port fsl_diu_name_to_port(const char *s)
298{
299 enum fsl_diu_monitor_port port = FSL_DIU_PORT_DVI;
300 unsigned long val;
301
302 if (s) {
303 if (!strict_strtoul(s, 10, &val) && (val <= 2))
304 port = (enum fsl_diu_monitor_port) val;
305 else if (strncmp(s, "lvds", 4) == 0)
306 port = FSL_DIU_PORT_LVDS;
307 else if (strncmp(s, "dlvds", 5) == 0)
308 port = FSL_DIU_PORT_DLVDS;
309 }
310
311 return diu_ops.valid_monitor_port(port);
312}
313
314/**
285 * fsl_diu_alloc - allocate memory for the DIU 315 * fsl_diu_alloc - allocate memory for the DIU
286 * @size: number of bytes to allocate 316 * @size: number of bytes to allocate
287 * @param: returned physical address of memory 317 * @param: returned physical address of memory
@@ -831,9 +861,8 @@ static int fsl_diu_set_par(struct fb_info *info)
831 } 861 }
832 } 862 }
833 863
834 ad->pix_fmt = 864 ad->pix_fmt = diu_ops.get_pixel_format(machine_data->monitor_port,
835 diu_ops.get_pixel_format(var->bits_per_pixel, 865 var->bits_per_pixel);
836 machine_data->monitor_port);
837 ad->addr = cpu_to_le32(info->fix.smem_start); 866 ad->addr = cpu_to_le32(info->fix.smem_start);
838 ad->src_size_g_alpha = cpu_to_le32((var->yres_virtual << 12) | 867 ad->src_size_g_alpha = cpu_to_le32((var->yres_virtual << 12) |
839 var->xres_virtual) | mfbi->g_alpha; 868 var->xres_virtual) | mfbi->g_alpha;
@@ -1439,16 +1468,12 @@ static void free_buf(struct device *dev, struct diu_addr *buf, u32 size,
1439static ssize_t store_monitor(struct device *device, 1468static ssize_t store_monitor(struct device *device,
1440 struct device_attribute *attr, const char *buf, size_t count) 1469 struct device_attribute *attr, const char *buf, size_t count)
1441{ 1470{
1442 int old_monitor_port; 1471 enum fsl_diu_monitor_port old_monitor_port;
1443 unsigned long val;
1444 struct fsl_diu_data *machine_data = 1472 struct fsl_diu_data *machine_data =
1445 container_of(attr, struct fsl_diu_data, dev_attr); 1473 container_of(attr, struct fsl_diu_data, dev_attr);
1446 1474
1447 if (strict_strtoul(buf, 10, &val))
1448 return 0;
1449
1450 old_monitor_port = machine_data->monitor_port; 1475 old_monitor_port = machine_data->monitor_port;
1451 machine_data->monitor_port = diu_ops.set_sysfs_monitor_port(val); 1476 machine_data->monitor_port = fsl_diu_name_to_port(buf);
1452 1477
1453 if (old_monitor_port != machine_data->monitor_port) { 1478 if (old_monitor_port != machine_data->monitor_port) {
1454 /* All AOIs need adjust pixel format 1479 /* All AOIs need adjust pixel format
@@ -1468,7 +1493,17 @@ static ssize_t show_monitor(struct device *device,
1468{ 1493{
1469 struct fsl_diu_data *machine_data = 1494 struct fsl_diu_data *machine_data =
1470 container_of(attr, struct fsl_diu_data, dev_attr); 1495 container_of(attr, struct fsl_diu_data, dev_attr);
1471 return diu_ops.show_monitor_port(machine_data->monitor_port, buf); 1496
1497 switch (machine_data->monitor_port) {
1498 case FSL_DIU_PORT_DVI:
1499 return sprintf(buf, "DVI\n");
1500 case FSL_DIU_PORT_LVDS:
1501 return sprintf(buf, "Single-link LVDS\n");
1502 case FSL_DIU_PORT_DLVDS:
1503 return sprintf(buf, "Dual-link LVDS\n");
1504 }
1505
1506 return 0;
1472} 1507}
1473 1508
1474static int __devinit fsl_diu_probe(struct platform_device *ofdev) 1509static int __devinit fsl_diu_probe(struct platform_device *ofdev)
@@ -1692,8 +1727,7 @@ static int __init fsl_diu_setup(char *options)
1692 if (!*opt) 1727 if (!*opt)
1693 continue; 1728 continue;
1694 if (!strncmp(opt, "monitor=", 8)) { 1729 if (!strncmp(opt, "monitor=", 8)) {
1695 if (!strict_strtoul(opt + 8, 10, &val) && (val <= 2)) 1730 monitor_port = fsl_diu_name_to_port(opt + 8);
1696 monitor_port = val;
1697 } else if (!strncmp(opt, "bpp=", 4)) { 1731 } else if (!strncmp(opt, "bpp=", 4)) {
1698 if (!strict_strtoul(opt + 4, 10, &val)) 1732 if (!strict_strtoul(opt + 4, 10, &val))
1699 default_bpp = val; 1733 default_bpp = val;
@@ -1746,6 +1780,8 @@ static int __init fsl_diu_init(void)
1746 if (fb_get_options("fslfb", &option)) 1780 if (fb_get_options("fslfb", &option))
1747 return -ENODEV; 1781 return -ENODEV;
1748 fsl_diu_setup(option); 1782 fsl_diu_setup(option);
1783#else
1784 monitor_port = fsl_diu_name_to_port(monitor_string);
1749#endif 1785#endif
1750 printk(KERN_INFO "Freescale DIU driver\n"); 1786 printk(KERN_INFO "Freescale DIU driver\n");
1751 1787
@@ -1812,7 +1848,7 @@ MODULE_PARM_DESC(mode,
1812 "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" "); 1848 "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
1813module_param_named(bpp, default_bpp, ulong, 0); 1849module_param_named(bpp, default_bpp, ulong, 0);
1814MODULE_PARM_DESC(bpp, "Specify bit-per-pixel if not specified mode"); 1850MODULE_PARM_DESC(bpp, "Specify bit-per-pixel if not specified mode");
1815module_param_named(monitor, monitor_port, int, 0); 1851module_param_named(monitor, monitor_string, charp, 0);
1816MODULE_PARM_DESC(monitor, 1852MODULE_PARM_DESC(monitor, "Specify the monitor port "
1817 "Specify the monitor port (0, 1 or 2) if supported by the platform"); 1853 "(\"dvi\", \"lvds\", or \"dlvds\") if supported by the platform");
1818 1854