linux/drivers/staging/gma500/psb_intel_drv.h
<<
>>
Prefs
   1/*
   2 * Copyright (c) 2009-2011, Intel Corporation.
   3 *
   4 * This program is free software; you can redistribute it and/or modify it
   5 * under the terms and conditions of the GNU General Public License,
   6 * version 2, as published by the Free Software Foundation.
   7 *
   8 * This program is distributed in the hope it will be useful, but WITHOUT
   9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  11 * more details.
  12 *
  13 * You should have received a copy of the GNU General Public License along with
  14 * this program; if not, write to the Free Software Foundation, Inc.,
  15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  16 *
  17 */
  18
  19#ifndef __INTEL_DRV_H__
  20#define __INTEL_DRV_H__
  21
  22#include <linux/i2c.h>
  23#include <linux/i2c-algo-bit.h>
  24#include <drm/drm_crtc.h>
  25#include <drm/drm_crtc_helper.h>
  26#include <linux/gpio.h>
  27
  28/*
  29 * Display related stuff
  30 */
  31
  32/* store information about an Ixxx DVO */
  33/* The i830->i865 use multiple DVOs with multiple i2cs */
  34/* the i915, i945 have a single sDVO i2c bus - which is different */
  35#define MAX_OUTPUTS 6
  36/* maximum connectors per crtcs in the mode set */
  37#define INTELFB_CONN_LIMIT 4
  38
  39#define INTEL_I2C_BUS_DVO 1
  40#define INTEL_I2C_BUS_SDVO 2
  41
  42/* these are outputs from the chip - integrated only
  43 * external chips are via DVO or SDVO output */
  44#define INTEL_OUTPUT_UNUSED 0
  45#define INTEL_OUTPUT_ANALOG 1
  46#define INTEL_OUTPUT_DVO 2
  47#define INTEL_OUTPUT_SDVO 3
  48#define INTEL_OUTPUT_LVDS 4
  49#define INTEL_OUTPUT_TVOUT 5
  50#define INTEL_OUTPUT_HDMI 6
  51#define INTEL_OUTPUT_MIPI 7
  52#define INTEL_OUTPUT_MIPI2 8
  53
  54#define INTEL_DVO_CHIP_NONE 0
  55#define INTEL_DVO_CHIP_LVDS 1
  56#define INTEL_DVO_CHIP_TMDS 2
  57#define INTEL_DVO_CHIP_TVOUT 4
  58
  59/*
  60 * Hold information useally put on the device driver privates here,
  61 * since it needs to be shared across multiple of devices drivers privates.
  62 */
  63struct psb_intel_mode_device {
  64
  65        /*
  66         * Abstracted memory manager operations
  67         */
  68         size_t(*bo_offset) (struct drm_device *dev, void *bo);
  69
  70        /*
  71         * Cursor (Can go ?)
  72         */
  73        int cursor_needs_physical;
  74
  75        /*
  76         * LVDS info
  77         */
  78        int backlight_duty_cycle;       /* restore backlight to this value */
  79        bool panel_wants_dither;
  80        struct drm_display_mode *panel_fixed_mode;
  81        struct drm_display_mode *panel_fixed_mode2;
  82        struct drm_display_mode *vbt_mode;      /* if any */
  83
  84        uint32_t saveBLC_PWM_CTL;
  85};
  86
  87struct psb_intel_i2c_chan {
  88        /* for getting at dev. private (mmio etc.) */
  89        struct drm_device *drm_dev;
  90        u32 reg;                /* GPIO reg */
  91        struct i2c_adapter adapter;
  92        struct i2c_algo_bit_data algo;
  93        u8 slave_addr;
  94};
  95
  96struct psb_intel_output {
  97        struct drm_connector base;
  98
  99        struct drm_encoder enc;
 100        int type;
 101
 102        struct psb_intel_i2c_chan *i2c_bus;     /* for control functions */
 103        struct psb_intel_i2c_chan *ddc_bus;     /* for DDC only stuff */
 104        bool load_detect_temp;
 105        void *dev_priv;
 106
 107        struct psb_intel_mode_device *mode_dev;
 108        struct i2c_adapter *hdmi_i2c_adapter;   /* for control functions */
 109};
 110
 111struct psb_intel_crtc_state {
 112        uint32_t saveDSPCNTR;
 113        uint32_t savePIPECONF;
 114        uint32_t savePIPESRC;
 115        uint32_t saveDPLL;
 116        uint32_t saveFP0;
 117        uint32_t saveFP1;
 118        uint32_t saveHTOTAL;
 119        uint32_t saveHBLANK;
 120        uint32_t saveHSYNC;
 121        uint32_t saveVTOTAL;
 122        uint32_t saveVBLANK;
 123        uint32_t saveVSYNC;
 124        uint32_t saveDSPSTRIDE;
 125        uint32_t saveDSPSIZE;
 126        uint32_t saveDSPPOS;
 127        uint32_t saveDSPBASE;
 128        uint32_t savePalette[256];
 129};
 130
 131struct psb_intel_crtc {
 132        struct drm_crtc base;
 133        int pipe;
 134        int plane;
 135        uint32_t cursor_addr;
 136        u8 lut_r[256], lut_g[256], lut_b[256];
 137        u8 lut_adj[256];
 138        struct psb_intel_framebuffer *fbdev_fb;
 139        /* a mode_set for fbdev users on this crtc */
 140        struct drm_mode_set mode_set;
 141
 142        /* GEM object that holds our cursor */
 143        struct drm_gem_object *cursor_obj;
 144
 145        struct drm_display_mode saved_mode;
 146        struct drm_display_mode saved_adjusted_mode;
 147
 148        struct psb_intel_mode_device *mode_dev;
 149
 150        /*crtc mode setting flags*/
 151        u32 mode_flags;
 152
 153        /* Saved Crtc HW states */
 154        struct psb_intel_crtc_state *crtc_state;
 155};
 156
 157#define to_psb_intel_crtc(x)    \
 158                container_of(x, struct psb_intel_crtc, base)
 159#define to_psb_intel_output(x)  \
 160                container_of(x, struct psb_intel_output, base)
 161#define enc_to_psb_intel_output(x)      \
 162                container_of(x, struct psb_intel_output, enc)
 163#define to_psb_intel_framebuffer(x)     \
 164                container_of(x, struct psb_intel_framebuffer, base)
 165
 166struct psb_intel_i2c_chan *psb_intel_i2c_create(struct drm_device *dev,
 167                                        const u32 reg, const char *name);
 168void psb_intel_i2c_destroy(struct psb_intel_i2c_chan *chan);
 169int psb_intel_ddc_get_modes(struct psb_intel_output *psb_intel_output);
 170extern bool psb_intel_ddc_probe(struct psb_intel_output *psb_intel_output);
 171
 172extern void psb_intel_crtc_init(struct drm_device *dev, int pipe,
 173                            struct psb_intel_mode_device *mode_dev);
 174extern void psb_intel_crt_init(struct drm_device *dev);
 175extern void psb_intel_sdvo_init(struct drm_device *dev, int output_device);
 176extern void psb_intel_dvo_init(struct drm_device *dev);
 177extern void psb_intel_tv_init(struct drm_device *dev);
 178extern void psb_intel_lvds_init(struct drm_device *dev,
 179                            struct psb_intel_mode_device *mode_dev);
 180extern void psb_intel_lvds_set_brightness(struct drm_device *dev, int level);
 181extern void mrst_lvds_init(struct drm_device *dev,
 182                           struct psb_intel_mode_device *mode_dev);
 183extern void mrst_wait_for_INTR_PKT_SENT(struct drm_device *dev);
 184extern void mrst_dsi_init(struct drm_device *dev,
 185                           struct psb_intel_mode_device *mode_dev);
 186extern void mid_dsi_init(struct drm_device *dev,
 187                    struct psb_intel_mode_device *mode_dev, int dsi_num);
 188
 189extern void psb_intel_crtc_load_lut(struct drm_crtc *crtc);
 190extern void psb_intel_encoder_prepare(struct drm_encoder *encoder);
 191extern void psb_intel_encoder_commit(struct drm_encoder *encoder);
 192
 193extern struct drm_encoder *psb_intel_best_encoder(struct drm_connector
 194                                              *connector);
 195
 196extern struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
 197                                                    struct drm_crtc *crtc);
 198extern void psb_intel_wait_for_vblank(struct drm_device *dev);
 199extern int psb_intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
 200                                struct drm_file *file_priv);
 201extern struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev,
 202                                                 int pipe);
 203extern struct drm_connector *psb_intel_sdvo_find(struct drm_device *dev,
 204                                             int sdvoB);
 205extern int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector);
 206extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
 207                                   int enable);
 208extern int intelfb_probe(struct drm_device *dev);
 209extern int intelfb_remove(struct drm_device *dev,
 210                          struct drm_framebuffer *fb);
 211extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device
 212                                                        *dev, struct
 213                                                        drm_mode_fb_cmd
 214                                                        *mode_cmd,
 215                                                        void *mm_private);
 216extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
 217                                      struct drm_display_mode *mode,
 218                                      struct drm_display_mode *adjusted_mode);
 219extern int psb_intel_lvds_mode_valid(struct drm_connector *connector,
 220                                     struct drm_display_mode *mode);
 221extern int psb_intel_lvds_set_property(struct drm_connector *connector,
 222                                        struct drm_property *property,
 223                                        uint64_t value);
 224extern void psb_intel_lvds_destroy(struct drm_connector *connector);
 225extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs;
 226
 227extern void mdfldWaitForPipeDisable(struct drm_device *dev, int pipe);
 228extern void mdfldWaitForPipeEnable(struct drm_device *dev, int pipe);
 229
 230#endif                          /* __INTEL_DRV_H__ */
 231