[PATCH 02/10] fbdev: xylon: Framebuffer driver core
Driver core functionality. Signed-off-by: Davor Joja --- drivers/video/fbdev/xylon/xylonfb_core.c | 1691 ++ drivers/video/fbdev/xylon/xylonfb_core.h | 252 + 2 files changed, 1943 insertions(+) create mode 100644 drivers/video/fbdev/xylon/xylonfb_core.c create mode 100644 drivers/video/fbdev/xylon/xylonfb_core.h diff --git a/drivers/video/fbdev/xylon/xylonfb_core.c b/drivers/video/fbdev/xylon/xylonfb_core.c new file mode 100644 index 000..9970215 --- /dev/null +++ b/drivers/video/fbdev/xylon/xylonfb_core.c @@ -0,0 +1,1691 @@ +/* + * Xylon logiCVC frame buffer driver core functions + * + * Copyright (C) 2015 Xylon d.o.o. + * Author: Davor Joja + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xylonfb_core.h" +#include "logicvc.h" + +#define LOGICVC_PIX_FMT_AYUV v4l2_fourcc('A', 'Y', 'U', 'V') +#define LOGICVC_PIX_FMT_AVUY v4l2_fourcc('A', 'V', 'U', 'Y') +#define LOGICVC_PIX_FMT_ALPHA v4l2_fourcc('A', '8', ' ', ' ') + +#define XYLONFB_PSEUDO_PALETTE_SIZE256 +#define XYLONFB_VRES_DEFAULT 1080 + +#define LOGICVC_COLOR_RGB_BLACK0 +#define LOGICVC_COLOR_RGB_WHITE0xFF +#define LOGICVC_COLOR_YUV888_BLACK 0x8080 +#define LOGICVC_COLOR_YUV888_WHITE 0xFF8080 + +char *xylonfb_mode_option; + +static const struct xylonfb_vmode xylonfb_vm = { + .vmode = { + .refresh = 60, + .xres = 1024, + .yres = 768, + .pixclock = KHZ2PICOS(65000), + .left_margin = 160, + .right_margin = 24, + .upper_margin = 29, + .lower_margin = 3, + .hsync_len = 136, + .vsync_len = 6, + .vmode = FB_VMODE_NONINTERLACED + }, + .name = "1024x768" +}; + +static int xylonfb_set_timings(struct fb_info *fbi, int bpp); +static void xylonfb_logicvc_disp_ctrl(struct fb_info *fbi, bool enable); +static void xylonfb_enable_logicvc_output(struct fb_info *fbi); +static void xylonfb_disable_logicvc_output(struct fb_info *fbi); +static void xylonfb_logicvc_layer_enable(struct fb_info *fbi, bool enable); +static void xylonfb_fbi_update(struct fb_info *fbi); + +static u32 xylonfb_get_reg(void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + return readl(base + offset); +} + +static void xylonfb_set_reg(u32 value, void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + writel(value, (base + offset)); +} + +static unsigned long xylonfb_get_reg_mem_addr(void __iomem *base, + unsigned int offset, + struct xylonfb_layer_data *ld) +{ + unsigned int ordinal = offset / LOGICVC_REG_STRIDE; + + if ((unsigned long)base - (unsigned long)ld->data->dev_base) { + return (unsigned long)(>regs) + (ordinal * sizeof(u32)); + } else { + ordinal -= (LOGICVC_CTRL_ROFF / LOGICVC_REG_STRIDE); + return (unsigned long)(>data->regs) + + (ordinal * sizeof(u32)); + } +} + +static u32 xylonfb_get_reg_mem(void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + return *((unsigned long *)xylonfb_get_reg_mem_addr(base, offset, ld)); +} + +static void xylonfb_set_reg_mem(u32 value, void __iomem *base, + unsigned int offset, + struct xylonfb_layer_data *ld) +{ + unsigned long *reg_mem_addr = + (unsigned long *)xylonfb_get_reg_mem_addr(base, offset, ld); + *reg_mem_addr = value; + writel((*reg_mem_addr), (base + offset)); +} + +static irqreturn_t xylonfb_isr(int irq, void *dev_id) +{ + struct fb_info **afbi = dev_get_drvdata(dev_id); + struct fb_info *fbi = afbi[0]; + struct xylonfb_layer_data *ld = fbi->par; + struct xylonfb_data *data = ld->data; + void __iomem *dev_base = data->dev_base; + u32 isr; + + XYLONFB_DBG(CORE, "%s", __func__); + + isr = readl(dev_base + LOGICVC_INT_STAT_ROFF); + if (isr & LOGICVC_INT_V_SYNC) { + writel(LOGICVC_INT_V_SYNC, dev_base + LOGICVC_INT_STAT_ROFF); + + data->vsync.count++; + + if (waitqueue_active(>vsync.wait)) +
[PATCH 02/10] fbdev: xylon: Framebuffer driver core
Driver core functionality. Signed-off-by: Davor Joja davorj...@logicbricks.com --- drivers/video/fbdev/xylon/xylonfb_core.c | 1691 ++ drivers/video/fbdev/xylon/xylonfb_core.h | 252 + 2 files changed, 1943 insertions(+) create mode 100644 drivers/video/fbdev/xylon/xylonfb_core.c create mode 100644 drivers/video/fbdev/xylon/xylonfb_core.h diff --git a/drivers/video/fbdev/xylon/xylonfb_core.c b/drivers/video/fbdev/xylon/xylonfb_core.c new file mode 100644 index 000..9970215 --- /dev/null +++ b/drivers/video/fbdev/xylon/xylonfb_core.c @@ -0,0 +1,1691 @@ +/* + * Xylon logiCVC frame buffer driver core functions + * + * Copyright (C) 2015 Xylon d.o.o. + * Author: Davor Joja davor.j...@logicbricks.com + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include linux/console.h +#include linux/delay.h +#include linux/dma-mapping.h +#include linux/interrupt.h +#include linux/module.h +#include linux/platform_device.h +#include linux/uaccess.h +#include linux/videodev2.h + +#include xylonfb_core.h +#include logicvc.h + +#define LOGICVC_PIX_FMT_AYUV v4l2_fourcc('A', 'Y', 'U', 'V') +#define LOGICVC_PIX_FMT_AVUY v4l2_fourcc('A', 'V', 'U', 'Y') +#define LOGICVC_PIX_FMT_ALPHA v4l2_fourcc('A', '8', ' ', ' ') + +#define XYLONFB_PSEUDO_PALETTE_SIZE256 +#define XYLONFB_VRES_DEFAULT 1080 + +#define LOGICVC_COLOR_RGB_BLACK0 +#define LOGICVC_COLOR_RGB_WHITE0xFF +#define LOGICVC_COLOR_YUV888_BLACK 0x8080 +#define LOGICVC_COLOR_YUV888_WHITE 0xFF8080 + +char *xylonfb_mode_option; + +static const struct xylonfb_vmode xylonfb_vm = { + .vmode = { + .refresh = 60, + .xres = 1024, + .yres = 768, + .pixclock = KHZ2PICOS(65000), + .left_margin = 160, + .right_margin = 24, + .upper_margin = 29, + .lower_margin = 3, + .hsync_len = 136, + .vsync_len = 6, + .vmode = FB_VMODE_NONINTERLACED + }, + .name = 1024x768 +}; + +static int xylonfb_set_timings(struct fb_info *fbi, int bpp); +static void xylonfb_logicvc_disp_ctrl(struct fb_info *fbi, bool enable); +static void xylonfb_enable_logicvc_output(struct fb_info *fbi); +static void xylonfb_disable_logicvc_output(struct fb_info *fbi); +static void xylonfb_logicvc_layer_enable(struct fb_info *fbi, bool enable); +static void xylonfb_fbi_update(struct fb_info *fbi); + +static u32 xylonfb_get_reg(void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + return readl(base + offset); +} + +static void xylonfb_set_reg(u32 value, void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + writel(value, (base + offset)); +} + +static unsigned long xylonfb_get_reg_mem_addr(void __iomem *base, + unsigned int offset, + struct xylonfb_layer_data *ld) +{ + unsigned int ordinal = offset / LOGICVC_REG_STRIDE; + + if ((unsigned long)base - (unsigned long)ld-data-dev_base) { + return (unsigned long)(ld-regs) + (ordinal * sizeof(u32)); + } else { + ordinal -= (LOGICVC_CTRL_ROFF / LOGICVC_REG_STRIDE); + return (unsigned long)(ld-data-regs) + + (ordinal * sizeof(u32)); + } +} + +static u32 xylonfb_get_reg_mem(void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + return *((unsigned long *)xylonfb_get_reg_mem_addr(base, offset, ld)); +} + +static void xylonfb_set_reg_mem(u32 value, void __iomem *base, + unsigned int offset, + struct xylonfb_layer_data *ld) +{ + unsigned long *reg_mem_addr = + (unsigned long *)xylonfb_get_reg_mem_addr(base, offset, ld); + *reg_mem_addr = value; + writel((*reg_mem_addr), (base + offset)); +} + +static irqreturn_t xylonfb_isr(int irq, void *dev_id) +{ + struct fb_info **afbi = dev_get_drvdata(dev_id); + struct fb_info *fbi = afbi[0]; + struct xylonfb_layer_data *ld = fbi-par; + struct xylonfb_data *data = ld-data; + void __iomem *dev_base = data-dev_base; + u32 isr; + + XYLONFB_DBG(CORE, %s, __func__); + + isr = readl(dev_base + LOGICVC_INT_STAT_ROFF); + if (isr LOGICVC_INT_V_SYNC) { +
[PATCH 02/10] fbdev: xylon: Framebuffer driver core
Driver core functionality. Signed-off-by: Davor Joja --- drivers/video/fbdev/xylon/xylonfb_core.c | 1691 ++ drivers/video/fbdev/xylon/xylonfb_core.h | 252 + 2 files changed, 1943 insertions(+) create mode 100644 drivers/video/fbdev/xylon/xylonfb_core.c create mode 100644 drivers/video/fbdev/xylon/xylonfb_core.h diff --git a/drivers/video/fbdev/xylon/xylonfb_core.c b/drivers/video/fbdev/xylon/xylonfb_core.c new file mode 100644 index 000..b20cedd --- /dev/null +++ b/drivers/video/fbdev/xylon/xylonfb_core.c @@ -0,0 +1,1691 @@ +/* + * Xylon logiCVC frame buffer driver core functions + * + * Copyright (C) 2014 Xylon d.o.o. + * Author: Davor Joja + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xylonfb_core.h" +#include "logicvc.h" + +#define LOGICVC_PIX_FMT_AYUV v4l2_fourcc('A', 'Y', 'U', 'V') +#define LOGICVC_PIX_FMT_AVUY v4l2_fourcc('A', 'V', 'U', 'Y') +#define LOGICVC_PIX_FMT_ALPHA v4l2_fourcc('A', '8', ' ', ' ') + +#define XYLONFB_PSEUDO_PALETTE_SIZE256 +#define XYLONFB_VRES_DEFAULT 1080 + +#define LOGICVC_COLOR_RGB_BLACK0 +#define LOGICVC_COLOR_RGB_WHITE0xFF +#define LOGICVC_COLOR_YUV888_BLACK 0x8080 +#define LOGICVC_COLOR_YUV888_WHITE 0xFF8080 + +char *xylonfb_mode_option; + +static const struct xylonfb_vmode xylonfb_vm = { + .vmode = { + .refresh = 60, + .xres = 1024, + .yres = 768, + .pixclock = KHZ2PICOS(65000), + .left_margin = 160, + .right_margin = 24, + .upper_margin = 29, + .lower_margin = 3, + .hsync_len = 136, + .vsync_len = 6, + .vmode = FB_VMODE_NONINTERLACED + }, + .name = "1024x768" +}; + +static int xylonfb_set_timings(struct fb_info *fbi, int bpp); +static void xylonfb_logicvc_disp_ctrl(struct fb_info *fbi, bool enable); +static void xylonfb_enable_logicvc_output(struct fb_info *fbi); +static void xylonfb_disable_logicvc_output(struct fb_info *fbi); +static void xylonfb_logicvc_layer_enable(struct fb_info *fbi, bool enable); +static void xylonfb_fbi_update(struct fb_info *fbi); + +static u32 xylonfb_get_reg(void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + return readl(base + offset); +} + +static void xylonfb_set_reg(u32 value, void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + writel(value, (base + offset)); +} + +static unsigned long xylonfb_get_reg_mem_addr(void __iomem *base, + unsigned int offset, + struct xylonfb_layer_data *ld) +{ + unsigned int ordinal = offset / LOGICVC_REG_STRIDE; + + if ((unsigned long)base - (unsigned long)ld->data->dev_base) { + return (unsigned long)(>regs) + (ordinal * sizeof(u32)); + } else { + ordinal -= (LOGICVC_CTRL_ROFF / LOGICVC_REG_STRIDE); + return (unsigned long)(>data->regs) + + (ordinal * sizeof(u32)); + } +} + +static u32 xylonfb_get_reg_mem(void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + return *((unsigned long *)xylonfb_get_reg_mem_addr(base, offset, ld)); +} + +static void xylonfb_set_reg_mem(u32 value, void __iomem *base, + unsigned int offset, + struct xylonfb_layer_data *ld) +{ + unsigned long *reg_mem_addr = + (unsigned long *)xylonfb_get_reg_mem_addr(base, offset, ld); + *reg_mem_addr = value; + writel((*reg_mem_addr), (base + offset)); +} + +static irqreturn_t xylonfb_isr(int irq, void *dev_id) +{ + struct fb_info **afbi = dev_get_drvdata(dev_id); + struct fb_info *fbi = afbi[0]; + struct xylonfb_layer_data *ld = fbi->par; + struct xylonfb_data *data = ld->data; + void __iomem *dev_base = data->dev_base; + u32 isr; + + XYLONFB_DBG(CORE, "%s", __func__); + + isr = readl(dev_base + LOGICVC_INT_STAT_ROFF); + if (isr & LOGICVC_INT_V_SYNC) { + writel(LOGICVC_INT_V_SYNC, dev_base + LOGICVC_INT_STAT_ROFF); + + data->vsync.count++; + + if (waitqueue_active(>vsync.wait)) +
[PATCH 02/10] fbdev: xylon: Framebuffer driver core
Driver core functionality. Signed-off-by: Davor Joja davorj...@logicbricks.com --- drivers/video/fbdev/xylon/xylonfb_core.c | 1691 ++ drivers/video/fbdev/xylon/xylonfb_core.h | 252 + 2 files changed, 1943 insertions(+) create mode 100644 drivers/video/fbdev/xylon/xylonfb_core.c create mode 100644 drivers/video/fbdev/xylon/xylonfb_core.h diff --git a/drivers/video/fbdev/xylon/xylonfb_core.c b/drivers/video/fbdev/xylon/xylonfb_core.c new file mode 100644 index 000..b20cedd --- /dev/null +++ b/drivers/video/fbdev/xylon/xylonfb_core.c @@ -0,0 +1,1691 @@ +/* + * Xylon logiCVC frame buffer driver core functions + * + * Copyright (C) 2014 Xylon d.o.o. + * Author: Davor Joja davor.j...@logicbricks.com + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include linux/console.h +#include linux/delay.h +#include linux/dma-mapping.h +#include linux/interrupt.h +#include linux/module.h +#include linux/platform_device.h +#include linux/uaccess.h +#include linux/videodev2.h + +#include xylonfb_core.h +#include logicvc.h + +#define LOGICVC_PIX_FMT_AYUV v4l2_fourcc('A', 'Y', 'U', 'V') +#define LOGICVC_PIX_FMT_AVUY v4l2_fourcc('A', 'V', 'U', 'Y') +#define LOGICVC_PIX_FMT_ALPHA v4l2_fourcc('A', '8', ' ', ' ') + +#define XYLONFB_PSEUDO_PALETTE_SIZE256 +#define XYLONFB_VRES_DEFAULT 1080 + +#define LOGICVC_COLOR_RGB_BLACK0 +#define LOGICVC_COLOR_RGB_WHITE0xFF +#define LOGICVC_COLOR_YUV888_BLACK 0x8080 +#define LOGICVC_COLOR_YUV888_WHITE 0xFF8080 + +char *xylonfb_mode_option; + +static const struct xylonfb_vmode xylonfb_vm = { + .vmode = { + .refresh = 60, + .xres = 1024, + .yres = 768, + .pixclock = KHZ2PICOS(65000), + .left_margin = 160, + .right_margin = 24, + .upper_margin = 29, + .lower_margin = 3, + .hsync_len = 136, + .vsync_len = 6, + .vmode = FB_VMODE_NONINTERLACED + }, + .name = 1024x768 +}; + +static int xylonfb_set_timings(struct fb_info *fbi, int bpp); +static void xylonfb_logicvc_disp_ctrl(struct fb_info *fbi, bool enable); +static void xylonfb_enable_logicvc_output(struct fb_info *fbi); +static void xylonfb_disable_logicvc_output(struct fb_info *fbi); +static void xylonfb_logicvc_layer_enable(struct fb_info *fbi, bool enable); +static void xylonfb_fbi_update(struct fb_info *fbi); + +static u32 xylonfb_get_reg(void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + return readl(base + offset); +} + +static void xylonfb_set_reg(u32 value, void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + writel(value, (base + offset)); +} + +static unsigned long xylonfb_get_reg_mem_addr(void __iomem *base, + unsigned int offset, + struct xylonfb_layer_data *ld) +{ + unsigned int ordinal = offset / LOGICVC_REG_STRIDE; + + if ((unsigned long)base - (unsigned long)ld-data-dev_base) { + return (unsigned long)(ld-regs) + (ordinal * sizeof(u32)); + } else { + ordinal -= (LOGICVC_CTRL_ROFF / LOGICVC_REG_STRIDE); + return (unsigned long)(ld-data-regs) + + (ordinal * sizeof(u32)); + } +} + +static u32 xylonfb_get_reg_mem(void __iomem *base, unsigned int offset, + struct xylonfb_layer_data *ld) +{ + return *((unsigned long *)xylonfb_get_reg_mem_addr(base, offset, ld)); +} + +static void xylonfb_set_reg_mem(u32 value, void __iomem *base, + unsigned int offset, + struct xylonfb_layer_data *ld) +{ + unsigned long *reg_mem_addr = + (unsigned long *)xylonfb_get_reg_mem_addr(base, offset, ld); + *reg_mem_addr = value; + writel((*reg_mem_addr), (base + offset)); +} + +static irqreturn_t xylonfb_isr(int irq, void *dev_id) +{ + struct fb_info **afbi = dev_get_drvdata(dev_id); + struct fb_info *fbi = afbi[0]; + struct xylonfb_layer_data *ld = fbi-par; + struct xylonfb_data *data = ld-data; + void __iomem *dev_base = data-dev_base; + u32 isr; + + XYLONFB_DBG(CORE, %s, __func__); + + isr = readl(dev_base + LOGICVC_INT_STAT_ROFF); + if (isr LOGICVC_INT_V_SYNC) { +