/////////////////////////////////////////////////////////////////////////////
// ns2keprm.h - NetStream 2000 TV EEPROM layout
// NetStream 2000 TV settings.
// Created by Jacques MAHE
// Copyright Sigma Designs Inc
// Sigma Designs Proprietary and confidential
// Created on 02/15/01
//
// BYTEs 0 to 7 are reserved.
//                                                     EEPROM ADDRESS
// BYTE RM_EEPROM_MUX                                        (8)
//    BIT0:  ENMUX0   (RC0)
//    BIT1: /ENMUX1   (RC1, Inverted)
//    BIT2: /SEL_MUX  (RC2, Inverted)
//    BIT3:  SCT-ENB  (RC3)
//    BIT4:  SCT-16*9 (RC4)
//    BIT5:  EN480P   (RB2),
//    BIT6:  SetRGB   (RB4)
//    BIT7:  YSyncEN  (RB5)
//
//    Notes:
//     - OUTPUT MODE           ENMUX0  ENMUX1  SEL_MUX
//         ADV Comp/S-Video       0       1       0
//         ADV RGB/YUV            0       1       0
//         FS Comp/S-Video        0       1       1
//         FS RGB/YUV             1       0       x
//         OFF                    1       1       x
//        (ADV=Analog Device, FS = Focus)
//     - We always set the output mode to focus when booting.
//     - Default (0) sets output to FS Comp/S-Video due to
//       ENMUX1 and SEL_MUX bit invertion.
//     - YSyncEN has to be set when outputting YUV or RGB
//     - SetRGB is indepedant and indicates RGB availability on scart
//
// BYTE RM_EEPROM_STD_MODE                                   (9)
//    Format:  SSCCPMMM
//             76543210
//    Where:   - SS is the Standard
//                RM_EEPROM_NTSC       (0)
//                RM_EEPROM_PAL        (1)
//                RM_EEPROM_480P       (2)
//             - CC is the SCART
//                RM_EEPROM_SCART_OFF  (0)
//                RM_EEPROM_SCART_4x3  (1)
//                RM_EEPROM_SCART_16x9 (2)
//             - P is the pedestal
//                1 when set           (0)
//             - MMM is the output mode
//                RM_EEPROM_COMPOSITE  (0)
//                RM_EEPROM_YUV        (1)
//                RM_EEPROM_RGB        (2)
//                RM_EEPROM_OFF        (3)
//    Notes: 
//      - We duplicate some bit meaning to make the EEPROM easier
//        to read. The following info details to correspondance.
//      - RM_EEPROM_MUX[3] == 0 when CC == RM_EEPROM_SCART_OFF
//        (else RM_EEPROM_MUX[4] is either 4x3 or 16x9)
//      - RM_EEPROM_MUX[4] == 1 when CC == RM_EEPROM_SCART_16x9
//      - RM_EEPROM_MUX[5] == 1 when SS == RM_EEPROM_480P
//
// BYTE RM_EEPROM_BRIGHTNESS                                 (10)
//    Format:  BBBBBBBB
//             76543210
//    Range: -128 to 127 included
//    Reg FS400_BRT = BBBBBBBB
//
// BYTE RM_EEPROM_CONTRAST                                   (11)
//    Format:  CCCCCCCC
//             76543210
//    Where:   - CCCCCCCC is the Contrast (Signed)
//                 Range: -32 to 31 included
//                 Reg FS400_CON = (CCCCCCCC + 32)
//
// BYTE RM_EEPROM_SATURATION                                 (12)
//    Format:  SSSSSSSS
//             76543210
//    Where:   - SSSSSSSS is the Saturation (Signed)
//                 Range: -32 to 31 included
//                 Reg FS400_CSC = (SSSSSSSS + 32)
//
// BYTE RM_EEPROM_SHARPNESS                                  (13)
//    Format:  SSSSSSSS
//             76543210
//    Where:   - SSSSSSSS is the Sharpness (Signed)
//                 Range: -8 to 23 included (32 values)
//                 Reg FS400_SHP = (SSSSSSSS + 8)
//
// BYTE RM_EEPROM_FLICKER                                    (14)
//    Format:  FFFFFFFF
//             76543210
//    Where:   - FFFFFFFF is the flicker filter (Unsigned)
//                 Range: -8 to 0 included (9 values)
//                 Reg FS400_SCR[15..12] = ((FFFFFFFF + 8) << 12)
//
//
// BYTE RM_EEPROM_DELTA_HOR_POS_LOW                          (15)
//    Note: used only on the first 200 NS2000TV
//    Low Byte
//    Format:  LLLLLLLL
//             76543210
// BYTE RM_EEPROM_DELTA_HOR_POS_HIGH                         (16)
//    Note: used only on the first 200 NS2000TV
//    High Byte
//    Format:  HHHHHHHH
//             FEDCBA98
//    Where:   - HHHHHHHH LLLLLLLL is the horizontal position offset
//                 Range: -32768 to 32767
//                 Reg FS400_HPO = HHHHHHHH LLLLLLLL
//
//
// BYTE RM_EEPROM_DELTA_VERT_POS_LOW                         (17)
//    Note: used only on the first 200 NS2000TV
//    Low Byte
//    Format:  LLLLLLLL
//             76543210
// BYTE RM_EEPROM_DELTA_VERT_POS_HIGH                        (18)
//    Note: used only on the first 200 NS2000TV
//    High Byte
//    Format:  HHHHHHHH
//             FEDCBA98
//    Where:   - HHHHHHHH LLLLLLLL is the vertical position offset
//                 Range: -32768 to 32767
//                 Reg FS400_VPO = HHHHHHHH LLLLLLLL
//
//
// BYTE RM_EEPROM_DELTA_HOR_SIZE_LOW                         (19)
//    Low Byte
//    Format:  LLLLLLLL
//             76543210
// BYTE RM_EEPROM_DELTA_HOR_SIZE_HIGH                        (20)
//    High Byte
//    Format:  HHHHHHHH
//             FEDCBA98
//    Where:   - HHHHHHHH LLLLLLLL is the horizontal scale step
//                 Range: -32768 to 32767
//                 Reg FS400_HSS = HHHHHHHH LLLLLLLL
//
//
// BYTE RM_EEPROM_DELTA_VERT_SIZE_LOW                        (21)
//    Low Byte
//    Format:  LLLLLLLL
//             76543210
// BYTE RM_EEPROM_DELTA_VERT_SIZE_HIGH                       (22)
//    High Byte
//    Format:  HHHHHHHH
//             FEDCBA98
//    Where:   - HHHHHHHH LLLLLLLL is the vertical scale step
//                 Range: -32768 to 32767
//                 Reg FS400_VSS = HHHHHHHH LLLLLLLL
//
// BYTE RM_EEPROM_DELTA_HOR_OFFSET_LOW                        (23)
//    Low Byte
//    Format:  LLLLLLLL
//             76543210
// BYTE RM_EEPROM_DELTA_HOR_OFFSET_HIGH                       (24)
//    High Byte
//    Format:  HHHHHHHH
//             FEDCBA98
//    Where:   - HHHHHHHH LLLLLLLL is the horizontal offset
//                 Range: -32768 to 32767
//                 Reg FS400_HOHOS = HHHHHHHH LLLLLLLL
//
// BYTE RM_EEPROM_DELTA_VERT_OFFSET_LOW                       (25)
//    Low Byte
//    Format:  LLLLLLLL
//             76543210
// BYTE RM_EEPROM_DELTA_VERT_OFFSET_HIGH                      (26)
//    High Byte
//    Format:  HHHHHHHH
//             FEDCBA98
//    Where:   - HHHHHHHH LLLLLLLL is the vertical offset
//                 Range: -32768 to 32767
//                 Reg FS400_HOVOS = HHHHHHHH LLLLLLLL
//
// BYTE RM_EEPROM_DELTA_TV_PIXELS_LOW                         (27)
//    Low Byte
//    Format:  LLLLLLLL
//             76543210
// BYTE RM_EEPROM_DELTA_TV_PIXELS_HIGH                        (28)
//    High Byte
//    Format:  HHHHHHHH
//             FEDCBA98
//    Where:   - HHHHHHHH LLLLLLLL is the horizontal offset
//                 Range: -32768 to 32767
//                 Reg FS400_TVL = HHHHHHHH LLLLLLLL
//
// BYTE RM_EEPROM_DELTA_TV_LINES_LOW                          (29)
//    Low Byte
//    Format:  LLLLLLLL
//             76543210
// BYTE RM_EEPROM_DELTA_TV_LINES_HIGH                         (30)
//    High Byte
//    Format:  HHHHHHHH
//             FEDCBA98
//    Where:   - HHHHHHHH LLLLLLLL is the vertical offset
//                 Range: -32768 to 32767
//                 Reg FS400_TVP = HHHHHHHH LLLLLLLL

#define RM_EEPROM_MUX                       8
#define RM_EEPROM_STD_MODE                  9
#define RM_EEPROM_BRIGHTNESS                10
#define RM_EEPROM_CONTRAST                  11
#define RM_EEPROM_SATURATION                12
#define RM_EEPROM_SHARPNESS                 13
#define RM_EEPROM_FLICKER                   14
#define RM_EEPROM_DELTA_HOR_POS_LOW         15
#define RM_EEPROM_DELTA_HOR_POS_HIGH        16
#define RM_EEPROM_DELTA_VERT_POS_LOW        17
#define RM_EEPROM_DELTA_VERT_POS_HIGH       18
#define RM_EEPROM_DELTA_HOR_SIZE_LOW        19
#define RM_EEPROM_DELTA_HOR_SIZE_HIGH       20
#define RM_EEPROM_DELTA_VERT_SIZE_LOW       21
#define RM_EEPROM_DELTA_VERT_SIZE_HIGH      22
#define RM_EEPROM_DELTA_HOR_OFFSET_LOW      23
#define RM_EEPROM_DELTA_HOR_OFFSET_HIGH     24
#define RM_EEPROM_DELTA_VERT_OFFSET_LOW     25
#define RM_EEPROM_DELTA_VERT_OFFSET_HIGH    26
#define RM_EEPROM_DELTA_TV_LINES_LOW        27
#define RM_EEPROM_DELTA_TV_LINES_HIGH       28
#define RM_EEPROM_DELTA_TV_PIXELS_LOW       29
#define RM_EEPROM_DELTA_TV_PIXELS_HIGH      30
#define RM_EEPROM_MUX_BACKUP                31

// RM_EEPROM_MUX

#define RMMASK_ENMUX0       0x01
#define RMMASK_I_ENMUX1     0x02    // I_ meaning inverted
#define RMMASK_I_SEL_MUX    0x04
#define RMMASK_SCT_ENB      0x08
#define RMMASK_SCT_16x9     0x10
#define RMMASK_EN480P       0x20
#define RMMASK_SETRGB       0x40
#define RMMASK_YSYNC_EN     0x80

// RM_EEPROM_STD_MODE 
//    Format:  SSCCPMMM

//    SS is the Standard
#define RM_EEPROM_NTSC       0
#define RM_EEPROM_PAL        1
#define RM_EEPROM_480P       2

#define RM_SET_EEPROM_STANDARD(n) ((n)<<6)

#define RM_EEPROM_NTSC_MASK  0x00
#define RM_EEPROM_PAL_MASK   0x40
#define RM_EEPROM_480P_MASK  0x80

//    CC is the SCART
#define RM_EEPROM_SCART_OFF  0
#define RM_EEPROM_SCART_4x3  1
#define RM_EEPROM_SCART_16x9 2

#define RM_SET_EEPROM_SCART(n) ((n)<<4)
#define RM_GET_EEPROM_SCART(n) (((n)>>4) & 0x03)

//    P is the pedestal
#define RM_PEDESTAL_OFF      0
#define RM_PEDESTAL_ON       1

#define RM_SET_EEPROM_PEDESTAL (1<<3)
#define RM_GET_EEPROM_PEDESTAL(n) ((n) & 0x08)

//    MMM is the output mode
#define RM_EEPROM_COMPOSITE  0
#define RM_EEPROM_YUV        1
#define RM_EEPROM_RGB        2
#define RM_EEPROM_TV_OFF     3

#define RM_SET_OUTPUT_MODE(n) (n)
#define RM_GET_OUTPUT_MODE(n) ((n) & 0x07)
