Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright 2007, 2008  Egbert Eich   <eich@novell.com>
  3.  * Copyright 2007, 2008  Luc Verhaegen <lverhaegen@novell.com>
  4.  * Copyright 2007, 2008  Matthias Hopf <mhopf@novell.com>
  5.  * Copyright 2007, 2008  Advanced Micro Devices, Inc.
  6.  *
  7.  * Permission is hereby granted, free of charge, to any person obtaining a
  8.  * copy of this software and associated documentation files (the "Software"),
  9.  * to deal in the Software without restriction, including without limitation
  10.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11.  * and/or sell copies of the Software, and to permit persons to whom the
  12.  * Software is furnished to do so, subject to the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice shall be included in
  15.  * all copies or substantial portions of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  20.  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23.  * OTHER DEALINGS IN THE SOFTWARE.
  24.  */
  25.  
  26.  
  27. #ifndef RHD_ATOMBIOS_H_
  28. # define RHD_ATOMBIOS_H_
  29.  
  30. # ifdef ATOM_BIOS
  31.  
  32. #define RHD_ATOMBIOS_ON 1
  33. #define RHD_ATOMBIOS_OFF 2
  34. #define RHD_ATOMBIOS_FORCE 4
  35. #define RHD_ATOMBIOS_CRTC 0
  36. #define RHD_ATOMBIOS_PLL 4
  37. #define RHD_ATOMBIOS_OUTPUT 8
  38.  
  39. typedef enum _AtomBiosRequestID {
  40.     ATOMBIOS_INIT,
  41.     ATOMBIOS_TEARDOWN,
  42. # ifdef ATOM_BIOS_PARSER
  43.     ATOMBIOS_EXEC,
  44. #  endif
  45.     ATOMBIOS_ALLOCATE_FB_SCRATCH,
  46.     ATOMBIOS_GET_CONNECTORS,
  47.     ATOMBIOS_GET_OUTPUT_DEVICE_LIST,
  48.     ATOMBIOS_GET_PANEL_MODE,
  49.     ATOMBIOS_GET_PANEL_EDID,
  50.     ATOMBIOS_GET_CODE_DATA_TABLE,
  51.     GET_DEFAULT_ENGINE_CLOCK,
  52.     GET_DEFAULT_MEMORY_CLOCK,
  53.     GET_MAX_PIXEL_CLOCK_PLL_OUTPUT,
  54.     GET_MIN_PIXEL_CLOCK_PLL_OUTPUT,
  55.     GET_MAX_PIXEL_CLOCK_PLL_INPUT,
  56.     GET_MIN_PIXEL_CLOCK_PLL_INPUT,
  57.     GET_MAX_PIXEL_CLK,
  58.     GET_REF_CLOCK,
  59.     GET_FW_FB_START,
  60.     GET_FW_FB_SIZE,
  61.     ATOM_TMDS_MAX_FREQUENCY,
  62.     ATOM_TMDS_PLL_CHARGE_PUMP,
  63.     ATOM_TMDS_PLL_DUTY_CYCLE,
  64.     ATOM_TMDS_PLL_VCO_GAIN,
  65.     ATOM_TMDS_PLL_VOLTAGE_SWING,
  66.     ATOM_LVDS_SUPPORTED_REFRESH_RATE,
  67.     ATOM_LVDS_OFF_DELAY,
  68.     ATOM_LVDS_SEQ_DIG_ONTO_DE,
  69.     ATOM_LVDS_SEQ_DE_TO_BL,
  70.     ATOM_LVDS_SPATIAL_DITHER,
  71.     ATOM_LVDS_TEMPORAL_DITHER,
  72.     ATOM_LVDS_DUALLINK,
  73.     ATOM_LVDS_24BIT,
  74.     ATOM_LVDS_GREYLVL,
  75.     ATOM_LVDS_FPDI,
  76.     ATOM_GPIO_QUERIES,
  77.     ATOM_GPIO_I2C_CLK_MASK,
  78.     ATOM_GPIO_I2C_CLK_MASK_SHIFT,
  79.     ATOM_GPIO_I2C_DATA_MASK,
  80.     ATOM_GPIO_I2C_DATA_MASK_SHIFT,
  81.     ATOM_DAC1_BG_ADJ,
  82.     ATOM_DAC1_DAC_ADJ,
  83.     ATOM_DAC1_FORCE,
  84.     ATOM_DAC2_CRTC2_BG_ADJ,
  85.     ATOM_DAC2_NTSC_BG_ADJ,
  86.     ATOM_DAC2_PAL_BG_ADJ,
  87.     ATOM_DAC2_CV_BG_ADJ,
  88.     ATOM_DAC2_CRTC2_DAC_ADJ,
  89.     ATOM_DAC2_NTSC_DAC_ADJ,
  90.     ATOM_DAC2_PAL_DAC_ADJ,
  91.     ATOM_DAC2_CV_DAC_ADJ,
  92.     ATOM_DAC2_CRTC2_FORCE,
  93.     ATOM_DAC2_CRTC2_MUX_REG_IND,
  94.     ATOM_DAC2_CRTC2_MUX_REG_INFO,
  95.     ATOM_ANALOG_TV_MODE,
  96.     ATOM_ANALOG_TV_DEFAULT_MODE,
  97.     ATOM_ANALOG_TV_SUPPORTED_MODES,
  98.     ATOM_GET_CONDITIONAL_GOLDEN_SETTINGS,
  99.     ATOM_GET_PCIENB_CFG_REG7,
  100.     ATOM_GET_CAPABILITY_FLAG,
  101.     ATOM_GET_PCIE_LANES,
  102.     ATOM_SET_REGISTER_LIST_LOCATION,
  103.     ATOM_RESTORE_REGISTERS,
  104.     FUNC_END
  105. } AtomBiosRequestID;
  106.  
  107. typedef enum _AtomBiosResult {
  108.     ATOM_SUCCESS,
  109.     ATOM_FAILED,
  110.     ATOM_NOT_IMPLEMENTED
  111. } AtomBiosResult;
  112.  
  113. typedef struct AtomExec {
  114.     int index;
  115.     pointer pspace;
  116.     pointer *dataSpace;
  117. } AtomExecRec, *AtomExecPtr;
  118.  
  119. typedef struct AtomFb {
  120.     unsigned int start;
  121.     unsigned int size;
  122. } AtomFbRec, *AtomFbPtr;
  123.  
  124. struct AtomDacCodeTableData
  125. {
  126.     CARD8 DAC1PALWhiteFine;
  127.     CARD8 DAC1PALBandGap;
  128.     CARD8 DAC1NTSCWhiteFine;
  129.     CARD8 DAC1NTSCBandGap;
  130.     CARD8 DAC1VGAWhiteFine;
  131.     CARD8 DAC1VGABandGap;
  132.     CARD8 DAC1CVWhiteFine;
  133.     CARD8 DAC1CVBandGap;
  134.     CARD8 DAC2PALWhiteFine;
  135.     CARD8 DAC2PALBandGap;
  136.     CARD8 DAC2NTSCWhiteFine;
  137.     CARD8 DAC2NTSCBandGap;
  138.     CARD8 DAC2VGAWhiteFine;
  139.     CARD8 DAC2VGABandGap;
  140.     CARD8 DAC2CVWhiteFine;
  141.     CARD8 DAC2CVBandGap;
  142. };
  143.  
  144. typedef enum AtomTVMode {
  145.     ATOM_TVMODE_NTSC = 1 << 0,
  146.     ATOM_TVMODE_NTSCJ = 1 << 1,
  147.     ATOM_TVMODE_PAL = 1 << 2,
  148.     ATOM_TVMODE_PALM = 1 << 3,
  149.     ATOM_TVMODE_PALCN = 1 << 4,
  150.     ATOM_TVMODE_PALN = 1 << 5,
  151.     ATOM_TVMODE_PAL60 = 1 << 6,
  152.     ATOM_TVMODE_SECAM = 1 << 7,
  153.     ATOM_TVMODE_CV = 1 << 8
  154. } AtomTVMode;
  155.  
  156. enum atomPCIELanes {
  157.     atomPCIELaneNONE,
  158.     atomPCIELane0_3,
  159.     atomPCIELane0_7,
  160.     atomPCIELane4_7,
  161.     atomPCIELane8_11,
  162.     atomPCIELane8_15,
  163.     atomPCIELane12_15
  164. };
  165.  
  166. enum atomDevice {
  167.     atomNone, /* 0 */
  168.     atomCRT1, /* 1 */
  169.     atomLCD1, /* 2 */
  170.     atomTV1,  /* 3 */
  171.     atomDFP1, /* 4 */
  172.     atomCRT2, /* 5 */
  173.     atomLCD2, /* 6 */
  174.     atomTV2,  /* 7 */
  175.     atomDFP2, /* 8 */
  176.     atomCV,   /* 9 */
  177.     atomDFP3, /* a */
  178.     atomDFP4, /* b */
  179.     atomDFP5  /* c */
  180. };
  181.  
  182. typedef struct AtomGoldenSettings
  183. {
  184.     unsigned char *BIOSPtr;
  185.     unsigned char *End;
  186.     unsigned int value;
  187.  
  188. } AtomGoldenSettings;
  189.  
  190. typedef union AtomBiosArg
  191. {
  192.     CARD32 val;
  193.     struct rhdConnectorInfo     *ConnectorInfo;
  194.     struct rhdAtomOutputDeviceList  *OutputDeviceList;
  195.     enum RHD_CHIPSETS           chipset;
  196.     struct AtomGoldenSettings   GoldenSettings;
  197.     unsigned char*              EDIDBlock;
  198.     void                       **Address;
  199.     struct {
  200.         unsigned char *loc;
  201.         unsigned short size;
  202.     } CommandDataTable;
  203.     struct {
  204.         enum atomPCIELanes      Chassis;
  205.         enum atomPCIELanes      Docking;
  206.     } pcieLanes;
  207.     atomBiosHandlePtr           atomhandle;
  208.     DisplayModePtr              mode;
  209.     AtomExecRec                 exec;
  210.     AtomFbRec                   fb;
  211.     enum RHD_TV_MODE            tvMode;
  212. } AtomBiosArgRec, *AtomBiosArgPtr;
  213.  
  214. enum atomCrtc {
  215.     atomCrtc1,
  216.     atomCrtc2
  217. };
  218.  
  219. enum atomCrtcAction {
  220.     atomCrtcEnable,
  221.     atomCrtcDisable
  222. };
  223.  
  224. enum atomOutputLinks {
  225.     atomSingleLink,
  226.     atomDualLink
  227. };
  228.  
  229. enum atomTransmitter {
  230.     atomTransmitterLVTMA,
  231.     atomTransmitterUNIPHY,
  232.     atomTransmitterUNIPHY1,
  233.     atomTransmitterUNIPHY2,
  234.     atomTransmitterPCIEPHY,
  235.     atomTransmitterDIG1,
  236.     atomTransmitterDIG2
  237. };
  238.  
  239. enum atomTransmitterAction {
  240.     atomTransDisable,
  241.     atomTransEnable,
  242.     atomTransEnableOutput,
  243.     atomTransDisableOutput,
  244.     atomTransInit,
  245.     atomTransLcdBlOff,
  246.     atomTransLcdBlOn,
  247.     atomTransLcdBlBrightness,
  248.     atomTransSetup
  249. };
  250.  
  251. enum atomEncoder {
  252.     atomEncoderNone,
  253.     atomEncoderDACA,
  254.     atomEncoderDACB,
  255.     atomEncoderTV,
  256.     atomEncoderTMDS1,  /* TMDSA */
  257.     atomEncoderTMDS2,  /* LVTMA */
  258.     atomEncoderLVDS,   /* LVTMA (Panel) */
  259.     atomEncoderDVO,
  260.     atomEncoderDIG1,
  261.     atomEncoderDIG2,
  262.     atomEncoderExternal
  263. };
  264.  
  265. enum atomEncoderMode {
  266.     atomNoEncoder,
  267.     atomDVI,
  268.     atomDP,
  269.     atomLVDS,
  270.     atomHDMI,
  271.     atomSDVO,
  272.     atomTVComposite,
  273.     atomTVSVideo,
  274.     atomTVComponent,
  275.     atomCRT
  276. };
  277.  
  278. enum atomEncoderAction {
  279.     atomEncoderOff,
  280.     atomEncoderOn
  281. };
  282.  
  283. enum atomOutput {
  284.     atomDVOOutput,
  285.     atomLCDOutput,
  286.     atomCVOutput,
  287.     atomTVOutput,
  288.     atomLVTMAOutput,
  289.     atomTMDSAOutput,
  290.     atomDAC1Output,
  291.     atomDAC2Output
  292. };
  293.  
  294. enum atomOutputType {
  295.     atomOutputNone,
  296.     atomOutputDacA,
  297.     atomOutputDacB,
  298.     atomOutputTmdsa,
  299.     atomOutputLvtma,
  300.     atomOutputDvo,
  301.     atomOutputKldskpLvtma,
  302.     atomOutputUniphyA,
  303.     atomOutputUniphyB,
  304.     atomOutputUniphyC,
  305.     atomOutputUniphyD,
  306.     atomOutputUniphyE,
  307.     atomOutputUniphyF
  308. };
  309.  
  310. enum atomOutputAction {
  311.     atomOutputEnable,
  312.     atomOutputDisable,
  313.     atomOutputLcdOn,
  314.     atomOutputLcdOff,
  315.     atomOutputLcdBrightnessControl,
  316.     atomOutputLcdSelftestStart,
  317.     atomOutputLcdSelftestStop,
  318.     atomOutputEncoderInit
  319. };
  320.  
  321. enum atomDAC {
  322.     atomDACA,
  323.     atomDACB,
  324.     atomDACExt
  325. };
  326.  
  327. enum atomTransmitterLink {
  328.     atomTransLinkA,
  329.     atomTransLinkAB,
  330.     atomTransLinkB,
  331.     atomTransLinkBA
  332. };
  333.  
  334. enum atomDACStandard {
  335.     atomDAC_VGA,
  336.     atomDAC_CV,
  337.     atomDAC_NTSC,
  338.     atomDAC_PAL
  339. };
  340.  
  341. enum atomDVORate {
  342.     atomDVO_RateSDR,
  343.     atomDVO_RateDDR
  344. };
  345.  
  346. enum atomDVOOutput {
  347.     atomDVO_OutputLow12Bit,
  348.     atomDVO_OutputHigh12Bit,
  349.     atomDVO_Output24Bit
  350. };
  351.  
  352. enum atomScaler {
  353.     atomScaler1,
  354.     atomScaler2
  355. };
  356.  
  357. enum atomScaleMode {
  358.     atomScaleDisable,
  359.     atomScaleCenter,
  360.     atomScaleExpand,
  361.     atomScaleMulttabExpand
  362. };
  363.  
  364. enum atomPxclk {
  365.     atomPclk1,
  366.     atomPclk2
  367. };
  368.  
  369. struct atomCodeTableVersion
  370. {
  371.     CARD8 cref;
  372.     CARD8 fref;
  373. };
  374.  
  375. enum atomTemporalGreyLevels {
  376.     atomTemporalDither0,
  377.     atomTemporalDither4,
  378.     atomTemporalDither2
  379. };
  380.  
  381. struct atomTransmitterConfig
  382. {
  383.     int PixelClock;
  384.     enum atomEncoder Encoder;
  385.     enum atomPCIELanes Lanes;
  386.     enum atomEncoderMode Mode;
  387.     enum atomTransmitterLink Link;
  388.     enum atomOutputLinks LinkCnt;
  389.     Bool Coherent;
  390. };
  391.  
  392. struct atomEncoderConfig
  393. {
  394.     int PixelClock;
  395.     union {
  396.         struct {
  397.             enum atomDACStandard DacStandard;
  398.         } dac;
  399.         struct {
  400.             enum RHD_TV_MODE TvStandard;
  401.         } tv;
  402.         struct {
  403.             enum atomOutputLinks LinkCnt;
  404.             Bool Is24bit;
  405.         } lvds;
  406.         struct {
  407.             enum atomOutputLinks LinkCnt;
  408.             Bool Is24bit;
  409.             Bool Coherent;
  410.             Bool LinkB;
  411.             Bool Hdmi;
  412.             Bool SpatialDither;
  413.             enum atomTemporalGreyLevels TemporalGrey;
  414.         } lvds2;
  415.         struct {
  416.             enum atomTransmitterLink Link;
  417.             enum atomOutputLinks LinkCnt;
  418.             enum atomTransmitter Transmitter;
  419.             enum atomEncoderMode EncoderMode;
  420.         } dig;
  421.         struct {
  422.             enum atomDevice DvoDeviceType;
  423.             int EncoderID;
  424.             Bool digital;
  425.             union
  426.             {
  427.                 enum RHD_TV_MODE TVMode;
  428.                 char dummy; /* @@@ placeholder for digital attributes */
  429.             } u;
  430.         } dvo;
  431.         struct{
  432.             enum atomDVORate Rate;
  433.             enum atomDVOOutput DvoOutput;
  434.         } dvo3;
  435.     } u;
  436. };
  437.  
  438. struct atomCrtcSourceConfig
  439. {
  440.     union {
  441.         enum atomDevice Device;
  442.         struct {
  443.             enum atomEncoder Encoder;
  444.             enum atomEncoderMode Mode;
  445.         } crtc2;
  446.     } u;
  447. };
  448.  
  449. struct atomPixelClockConfig {
  450.     Bool Enable;
  451.     int PixelClock;
  452.     int RefDiv;
  453.     int FbDiv;
  454.     int PostDiv;
  455.     int FracFbDiv;
  456.     enum atomCrtc Crtc;
  457.     union  {
  458.         struct {
  459.             Bool Force;
  460.             enum atomDevice Device;
  461.         } v2;
  462.         struct {
  463.             Bool Force;
  464.             enum atomOutputType OutputType;
  465.             enum atomEncoderMode EncoderMode;
  466.             Bool UsePpll;
  467.         } v3;
  468.     } u;
  469. };
  470.  
  471. struct atomCrtcOverscan {
  472.     unsigned short ovscnLeft;
  473.     unsigned short ovscnRight;
  474.     unsigned short ovscnTop;
  475.     unsigned short ovscnBottom;
  476. };
  477.  
  478. enum atomBlankAction {
  479.     atomBlankOn,
  480.     atomBlankOff
  481. };
  482.  
  483. struct atomCrtcBlank {
  484.     enum atomBlankAction Action;
  485.     unsigned short r, g, b;
  486. };
  487.  
  488. extern AtomBiosResult RHDAtomBiosFunc(RHDPtr rhdPtr, atomBiosHandlePtr handle,
  489.                 AtomBiosRequestID id, AtomBiosArgPtr data);
  490.  
  491. #  ifdef ATOM_BIOS_PARSER
  492. extern Bool rhdAtomSetTVEncoder(atomBiosHandlePtr handle, Bool enable, int mode);
  493.  
  494. #   if 0
  495. extern Bool rhdAtomASICInit(atomBiosHandlePtr handle);
  496. extern struct atomCodeTableVersion rhdAtomASICInitVersion(atomBiosHandlePtr handle);
  497. #   endif
  498. extern Bool rhdAtomSetScaler(atomBiosHandlePtr handle, enum atomScaler scaler,
  499.                              enum atomScaleMode mode);
  500. extern struct atomCodeTableVersion rhdAtomSetScalerVersion(atomBiosHandlePtr handle);
  501. extern Bool rhdAtomDigTransmitterControl(atomBiosHandlePtr handle, enum atomTransmitter id,
  502.                                          enum atomTransmitterAction action,
  503.                                          struct atomTransmitterConfig *config);
  504. extern struct atomCodeTableVersion rhdAtomDigTransmitterControlVersion(atomBiosHandlePtr handle);
  505. extern Bool rhdAtomOutputControl(atomBiosHandlePtr handle, enum atomOutput id,
  506.                                  enum atomOutputAction action);
  507. extern struct atomCodeTableVersion rhdAtomOutputControlVersion(atomBiosHandlePtr handle,
  508.                                                                enum atomOutput id);
  509. extern Bool AtomDACLoadDetection(atomBiosHandlePtr handle, enum atomDevice id, enum atomDAC dac);
  510. extern struct atomCodeTableVersion AtomDACLoadDetectionVersion(atomBiosHandlePtr handle, enum atomDevice id);
  511. extern Bool rhdAtomEncoderControl(atomBiosHandlePtr handle, enum atomEncoder id,
  512.                                   enum atomEncoderAction action, struct atomEncoderConfig *config);
  513. struct atomCodeTableVersion rhdAtomEncoderControlVersion(atomBiosHandlePtr handle,
  514. enum atomEncoder id);
  515. extern Bool rhdAtomUpdateCRTC_DoubleBufferRegisters(atomBiosHandlePtr handle, enum atomCrtc id,
  516.                               enum atomCrtcAction action);
  517. extern struct atomCodeTableVersion rhdAtomUpdateCRTC_DoubleBufferRegistersVersion(atomBiosHandlePtr handle);
  518. extern Bool rhdAtomEnableCrtc(atomBiosHandlePtr handle, enum atomCrtc id,
  519.                               enum atomCrtcAction action);
  520. extern struct atomCodeTableVersion rhdAtomEnableCrtcVersion(atomBiosHandlePtr handle);
  521. extern Bool rhdAtomEnableCrtcMemReq(atomBiosHandlePtr handle, enum atomCrtc id,
  522.                                     enum atomCrtcAction action);
  523. extern struct atomCodeTableVersion rhdAtomEnableCrtcMemReqVersion(atomBiosHandlePtr handle);
  524. extern Bool rhdAtomSetCRTCTimings(atomBiosHandlePtr handle, enum atomCrtc id, DisplayModePtr mode,
  525.                                   int depth);
  526. extern struct atomCodeTableVersion rhdAtomSetCRTCTimingsVersion(atomBiosHandlePtr handle);
  527. extern Bool rhdAtomSetPixelClock(atomBiosHandlePtr handle, enum atomPxclk id,
  528.                                  struct atomPixelClockConfig *config);
  529. extern struct atomCodeTableVersion rhdAtomSetPixelClockVersion(atomBiosHandlePtr handle);
  530. extern Bool rhdAtomSelectCrtcSource(atomBiosHandlePtr handle, enum atomCrtc id,
  531.                                     struct atomCrtcSourceConfig *config);
  532. extern struct atomCodeTableVersion rhdAtomSelectCrtcSourceVersion(atomBiosHandlePtr handle);
  533. extern Bool rhdAtomSetCRTCOverscan(atomBiosHandlePtr handle, enum atomCrtc id,
  534.                                    struct atomCrtcOverscan *config);
  535. struct atomCodeTableVersion rhdAtomSetCRTCOverscanVersion(atomBiosHandlePtr handle);
  536. extern Bool rhdAtomBlankCRTC(atomBiosHandlePtr handle, enum atomCrtc id, struct atomCrtcBlank *config);
  537. extern struct atomCodeTableVersion rhdAtomBlankCRTCVersion(atomBiosHandlePtr handle);
  538.  
  539. #  endif /* ATOM_BIOS_PASER */
  540.  
  541. # endif /* ATOM_BIOS */
  542.  
  543. #endif /*  RHD_ATOMBIOS_H_ */
  544.