Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * File: drivers/video/omap/omapfb.h
0004  *
0005  * Framebuffer driver for TI OMAP boards
0006  *
0007  * Copyright (C) 2004 Nokia Corporation
0008  * Author: Imre Deak <imre.deak@nokia.com>
0009  */
0010 
0011 #ifndef __OMAPFB_H
0012 #define __OMAPFB_H
0013 
0014 #include <linux/fb.h>
0015 #include <linux/mutex.h>
0016 #include <linux/omapfb.h>
0017 
0018 #define OMAPFB_EVENT_READY  1
0019 #define OMAPFB_EVENT_DISABLED   2
0020 
0021 #define OMAP_LCDC_INV_VSYNC             0x0001
0022 #define OMAP_LCDC_INV_HSYNC             0x0002
0023 #define OMAP_LCDC_INV_PIX_CLOCK         0x0004
0024 #define OMAP_LCDC_INV_OUTPUT_EN         0x0008
0025 #define OMAP_LCDC_HSVS_RISING_EDGE      0x0010
0026 #define OMAP_LCDC_HSVS_OPPOSITE         0x0020
0027 
0028 #define OMAP_LCDC_SIGNAL_MASK       0x003f
0029 
0030 #define OMAP_LCDC_PANEL_TFT     0x0100
0031 
0032 #define OMAPFB_PLANE_XRES_MIN       8
0033 #define OMAPFB_PLANE_YRES_MIN       8
0034 
0035 struct omapfb_device;
0036 
0037 #define OMAPFB_PLANE_NUM        1
0038 
0039 struct omapfb_mem_region {
0040     u32     paddr;
0041     void __iomem    *vaddr;
0042     unsigned long   size;
0043     u8      type;       /* OMAPFB_PLANE_MEM_* */
0044     enum omapfb_color_format format;/* OMAPFB_COLOR_* */
0045     unsigned    format_used:1;  /* Must be set when format is set.
0046                      * Needed b/c of the badly chosen 0
0047                      * base for OMAPFB_COLOR_* values
0048                      */
0049     unsigned    alloc:1;    /* allocated by the driver */
0050     unsigned    map:1;      /* kernel mapped by the driver */
0051 };
0052 
0053 struct omapfb_mem_desc {
0054     int             region_cnt;
0055     struct omapfb_mem_region    region[OMAPFB_PLANE_NUM];
0056 };
0057 
0058 struct lcd_panel {
0059     const char  *name;
0060     int     config;     /* TFT/STN, signal inversion */
0061     int     bpp;        /* Pixel format in fb mem */
0062     int     data_lines; /* Lines on LCD HW interface */
0063 
0064     int     x_res, y_res;
0065     int     pixel_clock;    /* In kHz */
0066     int     hsw;        /* Horizontal synchronization
0067                        pulse width */
0068     int     hfp;        /* Horizontal front porch */
0069     int     hbp;        /* Horizontal back porch */
0070     int     vsw;        /* Vertical synchronization
0071                        pulse width */
0072     int     vfp;        /* Vertical front porch */
0073     int     vbp;        /* Vertical back porch */
0074     int     acb;        /* ac-bias pin frequency */
0075     int     pcd;        /* pixel clock divider.
0076                        Obsolete use pixel_clock instead */
0077 
0078     int     (*init)     (struct lcd_panel *panel,
0079                      struct omapfb_device *fbdev);
0080     void        (*cleanup)  (struct lcd_panel *panel);
0081     int     (*enable)   (struct lcd_panel *panel);
0082     void        (*disable)  (struct lcd_panel *panel);
0083     unsigned long   (*get_caps) (struct lcd_panel *panel);
0084     int     (*set_bklight_level)(struct lcd_panel *panel,
0085                          unsigned int level);
0086     unsigned int    (*get_bklight_level)(struct lcd_panel *panel);
0087     unsigned int    (*get_bklight_max)  (struct lcd_panel *panel);
0088     int     (*run_test) (struct lcd_panel *panel, int test_num);
0089 };
0090 
0091 struct extif_timings {
0092     int cs_on_time;
0093     int cs_off_time;
0094     int we_on_time;
0095     int we_off_time;
0096     int re_on_time;
0097     int re_off_time;
0098     int we_cycle_time;
0099     int re_cycle_time;
0100     int cs_pulse_width;
0101     int access_time;
0102 
0103     int clk_div;
0104 
0105     u32 tim[5];     /* set by extif->convert_timings */
0106 
0107     int converted;
0108 };
0109 
0110 struct lcd_ctrl_extif {
0111     int  (*init)        (struct omapfb_device *fbdev);
0112     void (*cleanup)     (void);
0113     void (*get_clk_info)    (u32 *clk_period, u32 *max_clk_div);
0114     unsigned long (*get_max_tx_rate)(void);
0115     int  (*convert_timings) (struct extif_timings *timings);
0116     void (*set_timings) (const struct extif_timings *timings);
0117     void (*set_bits_per_cycle)(int bpc);
0118     void (*write_command)   (const void *buf, unsigned int len);
0119     void (*read_data)   (void *buf, unsigned int len);
0120     void (*write_data)  (const void *buf, unsigned int len);
0121     void (*transfer_area)   (int width, int height,
0122                  void (callback)(void *data), void *data);
0123     int  (*setup_tearsync)  (unsigned pin_cnt,
0124                  unsigned hs_pulse_time, unsigned vs_pulse_time,
0125                  int hs_pol_inv, int vs_pol_inv, int div);
0126     int  (*enable_tearsync) (int enable, unsigned line);
0127 
0128     unsigned long       max_transmit_size;
0129 };
0130 
0131 struct omapfb_notifier_block {
0132     struct notifier_block   nb;
0133     void            *data;
0134     int         plane_idx;
0135 };
0136 
0137 typedef int (*omapfb_notifier_callback_t)(struct notifier_block *,
0138                       unsigned long event,
0139                       void *fbi);
0140 
0141 struct lcd_ctrl {
0142     const char  *name;
0143     void        *data;
0144 
0145     int     (*init)       (struct omapfb_device *fbdev,
0146                        int ext_mode,
0147                        struct omapfb_mem_desc *req_md);
0148     void        (*cleanup)    (void);
0149     void        (*bind_client)    (struct omapfb_notifier_block *nb);
0150     void        (*get_caps)   (int plane, struct omapfb_caps *caps);
0151     int     (*set_update_mode)(enum omapfb_update_mode mode);
0152     enum omapfb_update_mode (*get_update_mode)(void);
0153     int     (*setup_plane)    (int plane, int channel_out,
0154                        unsigned long offset,
0155                        int screen_width,
0156                        int pos_x, int pos_y, int width,
0157                        int height, int color_mode);
0158     int     (*set_rotate)     (int angle);
0159     int     (*setup_mem)      (int plane, size_t size,
0160                        int mem_type, unsigned long *paddr);
0161     int     (*mmap)       (struct fb_info *info,
0162                        struct vm_area_struct *vma);
0163     int     (*set_scale)      (int plane,
0164                        int orig_width, int orig_height,
0165                        int out_width, int out_height);
0166     int     (*enable_plane)   (int plane, int enable);
0167     int     (*update_window)  (struct fb_info *fbi,
0168                        struct omapfb_update_window *win,
0169                        void (*callback)(void *),
0170                        void *callback_data);
0171     void        (*sync)       (void);
0172     void        (*suspend)    (void);
0173     void        (*resume)     (void);
0174     int     (*run_test)   (int test_num);
0175     int     (*setcolreg)      (u_int regno, u16 red, u16 green,
0176                        u16 blue, u16 transp,
0177                        int update_hw_mem);
0178     int     (*set_color_key)  (struct omapfb_color_key *ck);
0179     int     (*get_color_key)  (struct omapfb_color_key *ck);
0180 };
0181 
0182 enum omapfb_state {
0183     OMAPFB_DISABLED     = 0,
0184     OMAPFB_SUSPENDED    = 99,
0185     OMAPFB_ACTIVE       = 100
0186 };
0187 
0188 struct omapfb_plane_struct {
0189     int             idx;
0190     struct omapfb_plane_info    info;
0191     enum omapfb_color_format    color_mode;
0192     struct omapfb_device        *fbdev;
0193 };
0194 
0195 struct omapfb_device {
0196     int         state;
0197     int                     ext_lcdc;       /* Using external
0198                                LCD controller */
0199     struct mutex        rqueue_mutex;
0200 
0201     int         palette_size;
0202     u32         pseudo_palette[17];
0203 
0204     struct lcd_panel    *panel;         /* LCD panel */
0205     const struct lcd_ctrl   *ctrl;          /* LCD controller */
0206     const struct lcd_ctrl   *int_ctrl;      /* internal LCD ctrl */
0207     int         ext_irq;
0208     int         int_irq;
0209     struct lcd_ctrl_extif   *ext_if;        /* LCD ctrl external
0210                                interface */
0211     struct device       *dev;
0212     struct fb_var_screeninfo    new_var;    /* for mode changes */
0213 
0214     struct omapfb_mem_desc      mem_desc;
0215     struct fb_info          *fb_info[OMAPFB_PLANE_NUM];
0216 
0217     struct platform_device  *dssdev;    /* dummy dev for clocks */
0218 };
0219 
0220 extern struct lcd_ctrl omap1_lcd_ctrl;
0221 
0222 extern void omapfb_register_panel(struct lcd_panel *panel);
0223 extern void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval);
0224 extern void omapfb_notify_clients(struct omapfb_device *fbdev,
0225                   unsigned long event);
0226 extern int  omapfb_register_client(struct omapfb_notifier_block *nb,
0227                    omapfb_notifier_callback_t callback,
0228                    void *callback_data);
0229 extern int  omapfb_unregister_client(struct omapfb_notifier_block *nb);
0230 #endif /* __OMAPFB_H */