天天看點

SDVO-DVI-I2C-register

關于dvi視訊輸出口,微軟搞了個sdvo用來保護:

#define sdvo_output_first   (0)

#define sdvo_output_tmds0   (1 << 0)

#define sdvo_output_rgb0    (1 << 1)

#define sdvo_output_cvbs0   (1 << 2)

#define sdvo_output_svid0   (1 << 3)

#define sdvo_output_yprpb0  (1 << 4)

#define sdvo_output_scart0  (1 << 5)

#define sdvo_output_lvds0   (1 << 6)

#define sdvo_output_tmds1   (1 << 8)

#define sdvo_output_rgb1    (1 << 9)

#define sdvo_output_cvbs1   (1 << 10)

#define sdvo_output_svid1   (1 << 11)

#define sdvo_output_yprpb1  (1 << 12)

#define sdvo_output_scart1  (1 << 13)

#define sdvo_output_lvds1   (1 << 14)

#define sdvo_output_last    (14)

struct i830_sdvo_caps {

    uint8_t vendor_id;

    uint8_t device_id;

    uint8_t device_rev_id;

    uint8_t sdvo_version_major;

    uint8_t sdvo_version_minor;

    unsigned int sdvo_input_count:2;

    unsigned int smooth_scaling:1;

    unsigned int sharp_scaling:1;

    unsigned int up_scaling:1;

    unsigned int down_scaling:1;

    unsigned int stall_support:1;

    unsigned int pad:1;

    uint16_t output_flags;

} __attribute__((packed));

/** this matches the edid dtd structure, more or less */

struct i830_sdvo_dtd {

    struct {

 uint16_t clock;  /**< pixel clock, in 10khz units */

 uint8_t h_active; /**< lower 8 bits (pixels) */

 uint8_t h_blank; /**< lower 8 bits (pixels) */

 uint8_t h_high;  /**< upper 4 bits each h_active, h_blank */

 uint8_t v_active; /**< lower 8 bits (lines) */

 uint8_t v_blank; /**< lower 8 bits (lines) */

 uint8_t v_high;  /**< upper 4 bits each v_active, v_blank */

    } part1;

 uint8_t h_sync_off; /**< lower 8 bits, from hblank start */

 uint8_t h_sync_width; /**< lower 8 bits (pixels) */

 /** lower 4 bits each vsync offset, vsync width */

 uint8_t v_sync_off_width;

 /**

  * 2 high bits of hsync offset, 2 high bits of hsync width,

  * bits 4-5 of vsync offset, and 2 high bits of vsync width.

  */

 uint8_t sync_off_width_high;

 uint8_t dtd_flags;

 uint8_t sdvo_flags;

 /** bits 6-7 of vsync offset at bits 6-7 */

 uint8_t v_sync_off_high;

 uint8_t reserved;

    } part2;

struct i830_sdvo_pixel_clock_range {

    uint16_t min;   /**< pixel clock, in 10khz units */

    uint16_t max;   /**< pixel clock, in 10khz units */

struct i830_sdvo_preferred_input_timing_args {

    uint16_t clock;

    uint16_t width;

    uint16_t height;

/* i2c registers for sdvo */

#define sdvo_i2c_arg_0    0x07

#define sdvo_i2c_arg_1    0x06

#define sdvo_i2c_arg_2    0x05

#define sdvo_i2c_arg_3    0x04

#define sdvo_i2c_arg_4    0x03

#define sdvo_i2c_arg_5    0x02

#define sdvo_i2c_arg_6    0x01

#define sdvo_i2c_arg_7    0x00

#define sdvo_i2c_opcode    0x08

#define sdvo_i2c_cmd_status   0x09

#define sdvo_i2c_return_0   0x0a

#define sdvo_i2c_return_1   0x0b

#define sdvo_i2c_return_2   0x0c

#define sdvo_i2c_return_3   0x0d

#define sdvo_i2c_return_4   0x0e

#define sdvo_i2c_return_5   0x0f

#define sdvo_i2c_return_6   0x10

#define sdvo_i2c_return_7   0x11

#define sdvo_i2c_vendor_begin  0x20

/* status results */

#define sdvo_cmd_status_power_on  0x0

#define sdvo_cmd_status_success   0x1

#define sdvo_cmd_status_notsupp   0x2

#define sdvo_cmd_status_invalid_arg  0x3

#define sdvo_cmd_status_pending   0x4

#define sdvo_cmd_status_target_not_specified 0x5

#define sdvo_cmd_status_scaling_not_supp 0x6

/* sdvo commands, argument/result registers */

#define sdvo_cmd_reset     0x01

/** returns a struct i830_sdvo_caps */

#define sdvo_cmd_get_device_caps   0x02

#define sdvo_cmd_get_firmware_rev   0x86

# define sdvo_device_firmware_minor   sdvo_i2c_return_0

# define sdvo_device_firmware_major   sdvo_i2c_return_1

# define sdvo_device_firmware_patch   sdvo_i2c_return_2

/**

 * reports which inputs are trained (managed to sync).

 *

 * devices must have trained within 2 vsyncs of a mode change.

 */

#define sdvo_cmd_get_trained_inputs   0x03

struct i830_sdvo_get_trained_inputs_response {

    unsigned int input0_trained:1;

    unsigned int input1_trained:1;

    unsigned int pad:6;

/** returns a struct i830_sdvo_output_flags of active outputs. */

#define sdvo_cmd_get_active_outputs   0x04

 * sets the current set of active outputs.

 * takes a struct i830_sdvo_output_flags.  must be preceded by a set_in_out_map

 * on multi-output devices.

#define sdvo_cmd_set_active_outputs   0x05

 * returns the current mapping of sdvo inputs to outputs on the device.

 * returns two struct i830_sdvo_output_flags structures.

#define sdvo_cmd_get_in_out_map    0x06

struct i830_sdvo_in_out_map {

    uint16_t in0, in1;

};

 * sets the current mapping of sdvo inputs to outputs on the device.

 * takes two struct i380_sdvo_output_flags structures.

#define sdvo_cmd_set_in_out_map    0x07

 * returns a struct i830_sdvo_output_flags of attached displays.

#define sdvo_cmd_get_attached_displays   0x0b

 * returns a struct i830_sdvo_ouptut_flags of displays supporting hot plugging.

#define sdvo_cmd_get_hot_plug_support   0x0c

 * takes a struct i830_sdvo_output_flags.

#define sdvo_cmd_set_active_hot_plug   0x0d

 * returns a struct i830_sdvo_output_flags of displays with hot plug

 * interrupts enabled.

#define sdvo_cmd_get_active_hot_plug   0x0e

#define sdvo_cmd_get_interrupt_event_source  0x0f

struct i830_sdvo_get_interrupt_event_source_response {

    uint16_t interrupt_status;

    unsigned int ambient_light_interrupt:1;

    unsigned int pad:7;

 * selects which input is affected by future input commands.

 * commands affected include set_input_timings_part[12],

 * get_input_timings_part[12], get_preferred_input_timings_part[12],

 * get_input_pixel_clock_range, and create_preferred_input_timings.

#define sdvo_cmd_set_target_input   0x10

struct i830_sdvo_set_target_input_args {

    unsigned int target_1:1;

 * takes a struct i830_sdvo_output_flags of which outputs are targetted by

 * future output commands.

 * affected commands inclue set_output_timings_part[12],

 * get_output_timings_part[12], and get_output_pixel_clock_range.

#define sdvo_cmd_set_target_output   0x11

#define sdvo_cmd_get_input_timings_part1  0x12

#define sdvo_cmd_get_input_timings_part2  0x13

#define sdvo_cmd_set_input_timings_part1  0x14

#define sdvo_cmd_set_input_timings_part2  0x15

#define sdvo_cmd_set_output_timings_part1  0x16

#define sdvo_cmd_set_output_timings_part2  0x17

#define sdvo_cmd_get_output_timings_part1  0x18

#define sdvo_cmd_get_output_timings_part2  0x19

/* part 1 */

# define sdvo_dtd_clock_low    sdvo_i2c_arg_0

# define sdvo_dtd_clock_high    sdvo_i2c_arg_1

# define sdvo_dtd_h_active    sdvo_i2c_arg_2

# define sdvo_dtd_h_blank    sdvo_i2c_arg_3

# define sdvo_dtd_h_high    sdvo_i2c_arg_4

# define sdvo_dtd_v_active    sdvo_i2c_arg_5

# define sdvo_dtd_v_blank    sdvo_i2c_arg_6

# define sdvo_dtd_v_high    sdvo_i2c_arg_7

/* part 2 */

# define sdvo_dtd_hsync_off    sdvo_i2c_arg_0

# define sdvo_dtd_hsync_width    sdvo_i2c_arg_1

# define sdvo_dtd_vsync_off_width   sdvo_i2c_arg_2

# define sdvo_dtd_sync_off_width_high   sdvo_i2c_arg_3

# define sdvo_dtd_dtd_flags    sdvo_i2c_arg_4

# define sdvo_dtd_dtd_flag_interlaced    (1 << 7)

# define sdvo_dtd_dtd_flag_stereo_mask    (3 << 5)

# define sdvo_dtd_dtd_flag_input_mask    (3 << 3)

# define sdvo_dtd_dtd_flag_sync_mask    (3 << 1)

# define sdvo_dtd_sdvo_flas    sdvo_i2c_arg_5

# define sdvo_dtd_sdvo_flag_stall    (1 << 7)

# define sdvo_dtd_sdvo_flag_centered    (0 << 6)

# define sdvo_dtd_sdvo_flag_upper_left    (1 << 6)

# define sdvo_dtd_sdvo_flag_scaling_mask   (3 << 4)

# define sdvo_dtd_sdvo_flag_scaling_none   (0 << 4)

# define sdvo_dtd_sdvo_flag_scaling_sharp   (1 << 4)

# define sdvo_dtd_sdvo_flag_scaling_smooth   (2 << 4)

# define sdvo_dtd_vsync_off_high   sdvo_i2c_arg_6

 * generates a dtd based on the given width, height, and flags.

 * this will be supported by any device supporting scaling or interlaced

 * modes.

#define sdvo_cmd_create_preferred_input_timing  0x1a

# define sdvo_preferred_input_timing_clock_low  sdvo_i2c_arg_0

# define sdvo_preferred_input_timing_clock_high  sdvo_i2c_arg_1

# define sdvo_preferred_input_timing_width_low  sdvo_i2c_arg_2

# define sdvo_preferred_input_timing_width_high  sdvo_i2c_arg_3

# define sdvo_preferred_input_timing_height_low  sdvo_i2c_arg_4

# define sdvo_preferred_input_timing_height_high sdvo_i2c_arg_5

# define sdvo_preferred_input_timing_flags  sdvo_i2c_arg_6

# define sdvo_preferred_input_timing_flags_interlaced  (1 << 0)

# define sdvo_preferred_input_timing_flags_scaled  (1 << 1)

#define sdvo_cmd_get_preferred_input_timing_part1 0x1b

#define sdvo_cmd_get_preferred_input_timing_part2 0x1c

/** returns a struct i830_sdvo_pixel_clock_range */

#define sdvo_cmd_get_input_pixel_clock_range  0x1d

#define sdvo_cmd_get_output_pixel_clock_range  0x1e

/** returns a byte bitfield containing sdvo_clock_rate_mult_* flags */

#define sdvo_cmd_get_supported_clock_rate_mults  0x1f

/** returns a byte containing a sdvo_clock_rate_mult_* flag */

#define sdvo_cmd_get_clock_rate_mult   0x20

/** takes a byte containing a sdvo_clock_rate_mult_* flag */

#define sdvo_cmd_set_clock_rate_mult   0x21

# define sdvo_clock_rate_mult_1x    (1 << 0)

# define sdvo_clock_rate_mult_2x    (1 << 1)

# define sdvo_clock_rate_mult_4x    (1 << 3)

#define sdvo_cmd_get_supported_tv_formats  0x27

/** 5 bytes of bit flags for tv formats shared by all tv format functions */

struct i830_sdvo_tv_format {

    unsigned int ntsc_m:1;

    unsigned int ntsc_j:1;

    unsigned int ntsc_443:1;

    unsigned int pal_b:1;

    unsigned int pal_d:1;

    unsigned int pal_g:1;

    unsigned int pal_h:1;

    unsigned int pal_i:1;

    unsigned int pal_m:1;

    unsigned int pal_n:1;

    unsigned int pal_nc:1;

    unsigned int pal_60:1;

    unsigned int secam_b:1;

    unsigned int secam_d:1;

    unsigned int secam_g:1;

    unsigned int secam_k:1;

    unsigned int secam_k1:1;

    unsigned int secam_l:1;

    unsigned int secam_60:1;

    unsigned int hdtv_std_smpte_240m_1080i_59:1;

    unsigned int hdtv_std_smpte_240m_1080i_60:1;

    unsigned int hdtv_std_smpte_260m_1080i_59:1;

    unsigned int hdtv_std_smpte_260m_1080i_60:1;

    unsigned int hdtv_std_smpte_270m_1080i_50:1;

    unsigned int hdtv_std_smpte_274m_1080i_50:1;

    unsigned int hdtv_std_smpte_274m_1080i_59:1;

    unsigned int hdtv_std_smpte_274m_1080i_60:1;

    unsigned int hdtv_std_smpte_274m_1080p_23:1;

    unsigned int hdtv_std_smpte_274m_1080p_24:1;

    unsigned int hdtv_std_smpte_274m_1080p_25:1;

    unsigned int hdtv_std_smpte_274m_1080p_29:1;

    unsigned int hdtv_std_smpte_274m_1080p_50:1;

    unsigned int hdtv_std_smpte_274m_1080p_59:1;

    unsigned int hdtv_std_smpte_274m_1080p_60:1;

    unsigned int hdtv_std_smpte_295m_1080i_50:1;

    unsigned int hdtv_std_smpte_295m_1080p_50:1;

    unsigned int hdtv_std_smpte_296m_720p_59:1;

    unsigned int hdtv_std_smpte_296m_720p_60:1;

    unsigned int hdtv_std_smpte_296m_720p_50:1;

    unsigned int hdtv_std_smpte_293m_480p_59:1;

    unsigned int hdtv_std_smpte_270m_480i_59:1;

    unsigned int hdtv_std_iturbt601_576i_50:1;

    unsigned int hdtv_std_iturbt601_576p_50:1;

    unsigned int hdtv_std_eia_7702a_480i_60:1;

    unsigned int hdtv_std_eia_7702a_480p_60:1;

    unsigned int pad:3;

#define sdvo_cmd_get_tv_format    0x28

/** this command should be run before setoutputtimingspart[12] */

#define sdvo_cmd_set_tv_format    0x29

/** returns the resolutiosn that can be used with the given tv format */

#define sdvo_cmd_get_sdtv_resolution_support  0x83

struct i830_sdvo_sdtv_resolution_request {

struct i830_sdvo_sdtv_resolution_reply {

    unsigned int res_320x200:1;

    unsigned int res_320x240:1;

    unsigned int res_400x300:1;

    unsigned int res_640x350:1;

    unsigned int res_640x400:1;

    unsigned int res_640x480:1;

    unsigned int res_704x480:1;

    unsigned int res_704x576:1;

    unsigned int res_720x350:1;

    unsigned int res_720x400:1;

    unsigned int res_720x480:1;

    unsigned int res_720x540:1;

    unsigned int res_720x576:1;

    unsigned int res_800x600:1;

    unsigned int res_832x624:1;

    unsigned int res_920x766:1;

    unsigned int res_1024x768:1;

    unsigned int res_1280x1024:1;

    unsigned int pad:5;

#define sdvo_cmd_get_supported_power_states  0x2a

#define sdvo_cmd_get_encoder_power_state  0x2b

#define sdvo_cmd_set_encoder_power_state  0x2c

# define sdvo_encoder_state_on     (1 << 0)

# define sdvo_encoder_state_standby    (1 << 1)

# define sdvo_encoder_state_suspend    (1 << 2)

# define sdvo_encoder_state_off     (1 << 3)

#define sdvo_cmd_get_supported_enhancements  0x84

struct i830_sdvo_enhancements_reply {

    unsigned int flicker_filter:1;

    unsigned int flicker_filter_adaptive:1;

    unsigned int flicker_filter_2d:1;

    unsigned int saturation:1;

    unsigned int hue:1;

    unsigned int brightness:1;

    unsigned int contrast:1;

    unsigned int overscan_h:1;

    unsigned int overscan_v:1;

    unsigned int position_h:1;

    unsigned int position_v:1;

    unsigned int sharpness:1;

    unsigned int dot_crawl:1;

    unsigned int dither:1;

    unsigned int max_tv_chroma_filter:1;

    unsigned int max_tv_luma_filter:1;

/* picture enhancement limits below are dependent on the current tv format,

 * and thus need to be queried and set after it.

#define sdvo_cmd_get_max_flicker_fiter   0x4d

#define sdvo_cmd_get_max_adaptive_flicker_fiter  0x7b

#define sdvo_cmd_get_max_2d_flicker_fiter  0x52

#define sdvo_cmd_get_max_saturation   0x55

#define sdvo_cmd_get_max_hue    0x58

#define sdvo_cmd_get_max_brightness   0x5c

#define sdvo_cmd_get_max_contrast   0x5e

#define sdvo_cmd_get_max_overscan_h   0x61

#define sdvo_cmd_get_max_overscan_v   0x64

#define sdvo_cmd_get_max_position_h   0x67

#define sdvo_cmd_get_max_position_v   0x6a

#define sdvo_cmd_get_max_sharpness_v   0x6d

#define sdvo_cmd_get_max_tv_chroma   0x74

#define sdvo_cmd_get_max_tv_luma   0x77

struct i830_sdvo_enhancement_limits_reply {

    uint16_t max_value;

    uint16_t default_value;

#define sdvo_cmd_get_flicker_fiter   0x4d

#define sdvo_cmd_set_flicker_fiter   0x4e

#define sdvo_cmd_get_adaptive_flicker_fiter  0x50

#define sdvo_cmd_set_adaptive_flicker_fiter  0x51

#define sdvo_cmd_get_2d_flicker_fiter   0x53

#define sdvo_cmd_set_2d_flicker_fiter   0x54

#define sdvo_cmd_get_saturation    0x56

#define sdvo_cmd_set_saturation    0x57

#define sdvo_cmd_get_hue    0x59

#define sdvo_cmd_set_hue    0x5a

#define sdvo_cmd_get_brightness    0x5c

#define sdvo_cmd_set_brightness    0x5d

#define sdvo_cmd_get_contrast    0x5f

#define sdvo_cmd_set_contrast    0x60

#define sdvo_cmd_get_overscan_h    0x62

#define sdvo_cmd_set_overscan_h    0x63

#define sdvo_cmd_get_overscan_v    0x65

#define sdvo_cmd_set_overscan_v    0x66

#define sdvo_cmd_get_position_h    0x68

#define sdvo_cmd_set_position_h    0x69

#define sdvo_cmd_get_position_v    0x6b

#define sdvo_cmd_set_position_v    0x6c

#define sdvo_cmd_get_sharpness    0x6e

#define sdvo_cmd_set_sharpness    0x6f

#define sdvo_cmd_get_tv_chroma    0x75

#define sdvo_cmd_set_tv_chroma    0x76

#define sdvo_cmd_get_tv_luma    0x78

#define sdvo_cmd_set_tv_luma    0x79

struct i830_sdvo_enhancements_arg {

    uint16_t value;

}__attribute__((packed));

#define sdvo_cmd_get_dot_crawl    0x70

#define sdvo_cmd_set_dot_crawl    0x71

# define sdvo_dot_crawl_on     (1 << 0)

# define sdvo_dot_crawl_default_on    (1 << 1)

#define sdvo_cmd_get_dither    0x72

#define sdvo_cmd_set_dither    0x73

# define sdvo_dither_on      (1 << 0)

# define sdvo_dither_default_on     (1 << 1)

#define sdvo_cmd_set_tv_resolution_support  0x93

#define sdvo_cmd_set_control_bus_switch   0x7a

# define sdvo_control_bus_prom    (1 << 0)

# define sdvo_control_bus_ddc1    (1 << 1)

# define sdvo_control_bus_ddc2    (1 << 2)

# define sdvo_control_bus_ddc3    (1 << 3)

/* hdmi op codes */

#define sdvo_cmd_get_supp_encode 0x9d

#define sdvo_cmd_get_encode  0x9e

#define sdvo_cmd_set_encode  0x9f

  #define sdvo_encode_dvi 0x0

  #define sdvo_encode_hdmi 0x1

#define sdvo_cmd_set_pixel_repli 0x8b

#define sdvo_cmd_get_pixel_repli 0x8c

#define sdvo_cmd_get_colorimetry_cap 0x8d

#define sdvo_cmd_set_colorimetry 0x8e

  #define sdvo_colorimetry_rgb256   0x0

  #define sdvo_colorimetry_rgb220   0x1

  #define sdvo_colorimetry_ycrcb422 0x3

  #define sdvo_colorimetry_ycrcb444 0x4

#define sdvo_cmd_get_colorimetry 0x8f

#define sdvo_cmd_get_audio_encrypt_prefer 0x90

#define sdvo_cmd_set_audio_stat  0x91

#define sdvo_cmd_get_audio_stat  0x92

#define sdvo_cmd_set_hbuf_index  0x93

#define sdvo_cmd_get_hbuf_index  0x94

#define sdvo_cmd_get_hbuf_info  0x95

#define sdvo_cmd_set_hbuf_av_split 0x96

#define sdvo_cmd_get_hbuf_av_split 0x97

#define sdvo_cmd_set_hbuf_data  0x98

#define sdvo_cmd_get_hbuf_data  0x99

#define sdvo_cmd_set_hbuf_txrate 0x9a

#define sdvo_cmd_get_hbuf_txrate 0x9b

  #define sdvo_hbuf_tx_disabled (0 << 6)

  #define sdvo_hbuf_tx_once (2 << 6)

  #define sdvo_hbuf_tx_vsync (3 << 6)

#define sdvo_cmd_get_audio_tx_info 0x9c

struct i830_sdvo_encode{

    uint8_t dvi_rev;

    uint8_t hdmi_rev;

} __attribute__ ((packed));