xref: /haiku/src/add-ons/accelerants/nvidia/engine/nv_proto.h (revision 268f99dd7dc4bd7474a8bd2742d3f1ec1de6752a)
155ec61f4Sshatty /* general card functions */
25aa72126Sshatty status_t nv_general_powerup(void);
35aa72126Sshatty status_t nv_set_cas_latency(void);
430f76422SRudolf Cornelissen void setup_virtualized_heads(bool);
564c14e7eSRudolf Cornelissen void set_crtc_owner(bool);
60669fe20SRudolf Cornelissen status_t nv_general_output_select(bool);
706f4c439SRudolf Cornelissen status_t nv_general_head_select(bool);
805ed3229SRudolf Cornelissen status_t nv_general_validate_pic_size (display_mode *target, uint32 *bytes_per_row, bool *acc_mode);
955ec61f4Sshatty 
105f1edbfbSRudolf Cornelissen /* AGP functions */
11d7dcafe7SRudolf Cornelissen status_t nv_agp_setup(bool enable_agp);
125f1edbfbSRudolf Cornelissen 
1355ec61f4Sshatty /* apsed: logging macros */
1455ec61f4Sshatty #define MSG(args) do { /* if needed or si->settings with si NULL */ \
1555ec61f4Sshatty 	nv_log args; \
1655ec61f4Sshatty } while (0)
1755ec61f4Sshatty #define LOG(level_bit, args) do { \
1855ec61f4Sshatty 	uint32 mod = (si->settings.logmask &  0xfffffff0) & MODULE_BIT; \
1955ec61f4Sshatty 	uint32 lev = (si->settings.logmask & ~0xfffffff0) & level_bit; \
2055ec61f4Sshatty 	if (mod && lev) nv_log args; \
2155ec61f4Sshatty } while (0)
2255ec61f4Sshatty 
2355ec61f4Sshatty /* support functions */
2455ec61f4Sshatty void delay(bigtime_t i);
2555ec61f4Sshatty void nv_log(char *format, ...);
2655ec61f4Sshatty 
2704e6b7ceSRudolf Cornelissen /* i2c functions */
2812566cbdSRudolf Cornelissen status_t i2c_sec_tv_adapter(void);
2912566cbdSRudolf Cornelissen char i2c_flag_error (char ErrNo);
3012566cbdSRudolf Cornelissen void i2c_bstart (uint8 BusNR);
3112566cbdSRudolf Cornelissen void i2c_bstop (uint8 BusNR);
3212566cbdSRudolf Cornelissen uint8 i2c_readbyte(uint8 BusNR, bool Ack);
3312566cbdSRudolf Cornelissen bool i2c_writebyte (uint8 BusNR, uint8 byte);
340ece4905SRudolf Cornelissen void i2c_readbuffer (uint8 BusNR, uint8* buf, uint8 size);
350ece4905SRudolf Cornelissen void i2c_writebuffer (uint8 BusNR, uint8* buf, uint8 size);
3655ec61f4Sshatty status_t i2c_init(void);
37bb0ac358SRudolf Cornelissen void i2c_TestEDID(void);
3821bade01SRudolf Cornelissen void i2c_DetectScreens(void);
3955ec61f4Sshatty 
4055ec61f4Sshatty /* card info functions */
4155ec61f4Sshatty status_t parse_pins(void);
42912ea16eSRudolf Cornelissen void set_pll(uint32 reg, uint32 clk);
430fccffc2SRudolf Cornelissen void get_panel_modes(display_mode *p1, display_mode *p2, bool *pan1, bool *pan2);
4451842d6eSRudolf Cornelissen void fake_panel_start(void);
4542529205SRudolf Cornelissen status_t get_crtc1_screen_native_mode(display_mode *mode);
4642529205SRudolf Cornelissen status_t get_crtc2_screen_native_mode(display_mode *mode);
4751842d6eSRudolf Cornelissen void set_specs(void);
4855ec61f4Sshatty void dump_pins(void);
4955ec61f4Sshatty 
5055ec61f4Sshatty /* DAC functions */
519f21ce69SRudolf Cornelissen bool nv_dac_crt_connected(void);
5255ec61f4Sshatty status_t nv_dac_mode(int,float);
53b793b9cbSRudolf Cornelissen status_t nv_dac_dither(bool dither);
54*eeddcfffSAugustin Cavalier status_t nv_dac_palette(uint8 r[256],uint8 g[256],uint8 b[256]);
5555ec61f4Sshatty status_t nv_dac_pix_pll_find(display_mode target,float * result,uint8 *,uint8 *,uint8 *, uint8);
5655ec61f4Sshatty status_t nv_dac_set_pix_pll(display_mode target);
5752e0509dSRudolf Cornelissen status_t nv_dac_sys_pll_find(float, float*, uint8*, uint8*, uint8*, uint8);
5855ec61f4Sshatty 
59a3b9d212SRudolf Cornelissen /* DAC2 functions */
609f21ce69SRudolf Cornelissen bool nv_dac2_crt_connected(void);
61a3b9d212SRudolf Cornelissen status_t nv_dac2_mode(int,float);
62*eeddcfffSAugustin Cavalier status_t nv_dac2_palette(uint8 r[256],uint8 g[256],uint8 b[256]);
63a3b9d212SRudolf Cornelissen status_t nv_dac2_pix_pll_find(display_mode target,float * result,uint8 *,uint8 *,uint8 *, uint8);
64a3b9d212SRudolf Cornelissen status_t nv_dac2_set_pix_pll(display_mode target);
6555ec61f4Sshatty 
6612566cbdSRudolf Cornelissen /* Brooktree TV functions */
6712566cbdSRudolf Cornelissen bool BT_probe(void);
683aa21459SRudolf Cornelissen uint8 BT_dpms(bool display);
69b2459715SRudolf Cornelissen uint8 BT_check_tvmode(display_mode target);
7022a0d15bSRudolf Cornelissen status_t BT_stop_tvout(void);
71b2459715SRudolf Cornelissen status_t BT_setmode(display_mode target);
7255ec61f4Sshatty 
7355ec61f4Sshatty /* CRTC1 functions */
74155a2ad0SRudolf Cornelissen status_t nv_crtc_interrupt_enable(bool);
7582581f54SRudolf Cornelissen status_t nv_crtc_update_fifo(void);
7655ec61f4Sshatty status_t nv_crtc_validate_timing(
7755ec61f4Sshatty 	uint16 *hd_e,uint16 *hs_s,uint16 *hs_e,uint16 *ht,
78bfecd0cdSRudolf Cornelissen 	uint16 *vd_e,uint16 *vs_s,uint16 *vs_e,uint16 *vt);
7955ec61f4Sshatty status_t nv_crtc_set_timing(display_mode target);
8055ec61f4Sshatty status_t nv_crtc_depth(int mode);
8155ec61f4Sshatty status_t nv_crtc_set_display_start(uint32 startadd,uint8 bpp);
825aa72126Sshatty status_t nv_crtc_set_display_pitch(void);
834022652cSRudolf Cornelissen status_t nv_crtc_dpms(bool, bool, bool, bool);
8455ec61f4Sshatty status_t nv_crtc_mem_priority(uint8);
85bfecd0cdSRudolf Cornelissen status_t nv_crtc_cursor_init(void);
8655ec61f4Sshatty status_t nv_crtc_cursor_define(uint8*,uint8*);
8755ec61f4Sshatty status_t nv_crtc_cursor_position(uint16 x ,uint16 y);
885aa72126Sshatty status_t nv_crtc_cursor_show(void);
895aa72126Sshatty status_t nv_crtc_cursor_hide(void);
9091731297SRudolf Cornelissen status_t nv_crtc_stop_tvout(void);
9191731297SRudolf Cornelissen status_t nv_crtc_start_tvout(void);
9255ec61f4Sshatty 
9355ec61f4Sshatty /* CRTC2 functions */
94155a2ad0SRudolf Cornelissen status_t nv_crtc2_interrupt_enable(bool);
95a393eaf8SRudolf Cornelissen status_t nv_crtc2_update_fifo(void);
96ff50d0d1SRudolf Cornelissen status_t nv_crtc2_validate_timing(
97ff50d0d1SRudolf Cornelissen 	uint16 *hd_e,uint16 *hs_s,uint16 *hs_e,uint16 *ht,
98bfecd0cdSRudolf Cornelissen 	uint16 *vd_e,uint16 *vs_s,uint16 *vs_e,uint16 *vt);
99ff50d0d1SRudolf Cornelissen status_t nv_crtc2_set_timing(display_mode target);
100ff50d0d1SRudolf Cornelissen status_t nv_crtc2_depth(int mode);
101ff50d0d1SRudolf Cornelissen status_t nv_crtc2_set_display_start(uint32 startadd,uint8 bpp);
102ff50d0d1SRudolf Cornelissen status_t nv_crtc2_set_display_pitch(void);
1034022652cSRudolf Cornelissen status_t nv_crtc2_dpms(bool, bool, bool, bool);
104ff50d0d1SRudolf Cornelissen status_t nv_crtc2_mem_priority(uint8);
10504e6b7ceSRudolf Cornelissen status_t nv_crtc2_cursor_init(void);
106ff50d0d1SRudolf Cornelissen status_t nv_crtc2_cursor_define(uint8*,uint8*);
107ff50d0d1SRudolf Cornelissen status_t nv_crtc2_cursor_position(uint16 x ,uint16 y);
108ff50d0d1SRudolf Cornelissen status_t nv_crtc2_cursor_show(void);
109ff50d0d1SRudolf Cornelissen status_t nv_crtc2_cursor_hide(void);
11091731297SRudolf Cornelissen status_t nv_crtc2_stop_tvout(void);
11191731297SRudolf Cornelissen status_t nv_crtc2_start_tvout(void);
11255ec61f4Sshatty 
11355ec61f4Sshatty /* acceleration functions */
114e48ec1b5SRudolf Cornelissen //offscreen_buffer_config, cliprect and clipped_scaled_blit_params are here temporary..
115e48ec1b5SRudolf Cornelissen typedef struct {
116e48ec1b5SRudolf Cornelissen 	void*	buffer;						/* pointer to first byte of frame */
117e48ec1b5SRudolf Cornelissen 										/* buffer in virtual memory */
118e48ec1b5SRudolf Cornelissen 
119e48ec1b5SRudolf Cornelissen 	void*	buffer_dma;					/* pointer to first byte of frame */
120e48ec1b5SRudolf Cornelissen 										/* buffer in physical memory for DMA */
121e48ec1b5SRudolf Cornelissen 
122e48ec1b5SRudolf Cornelissen 	uint32	bytes_per_row;				/* number of bytes in one */
123e48ec1b5SRudolf Cornelissen 										/* virtual_width line */
124e48ec1b5SRudolf Cornelissen 										/* not neccesarily the same as */
125e48ec1b5SRudolf Cornelissen 										/* virtual_width * byte_per_pixel */
126e48ec1b5SRudolf Cornelissen 
127e48ec1b5SRudolf Cornelissen 	uint32	space;						/* pixel configuration */
128e48ec1b5SRudolf Cornelissen } offscreen_buffer_config;
129e48ec1b5SRudolf Cornelissen 
130e48ec1b5SRudolf Cornelissen typedef struct {
131e48ec1b5SRudolf Cornelissen 	uint16	left;						/* offset */
132e48ec1b5SRudolf Cornelissen 	uint16	top;
133e48ec1b5SRudolf Cornelissen 	uint16	width;						/* 0 to N, where zero means one */
134e48ec1b5SRudolf Cornelissen 										/* pixel, one means two pixels, */
135e48ec1b5SRudolf Cornelissen 										/* etc. */
136e48ec1b5SRudolf Cornelissen 	uint16	height;						/* 0 to M, where zero means one */
137e48ec1b5SRudolf Cornelissen 										/* line, one means two lines, etc. */
138e48ec1b5SRudolf Cornelissen } cliprect;
139e48ec1b5SRudolf Cornelissen 
140e48ec1b5SRudolf Cornelissen typedef struct {
141e48ec1b5SRudolf Cornelissen 	uint16		src_left;				/* offset within source rectangle */
142e48ec1b5SRudolf Cornelissen 	uint16		src_top;
143e48ec1b5SRudolf Cornelissen 	uint16		src_width;				/* 0 to N, where zero means one */
144e48ec1b5SRudolf Cornelissen 										/* pixel, one means two pixels, */
145e48ec1b5SRudolf Cornelissen 										/* etc. */
146e48ec1b5SRudolf Cornelissen 	uint16		src_height;				/* 0 to M, where zero means one */
147e48ec1b5SRudolf Cornelissen 										/* line, one means two lines, etc. */
148e48ec1b5SRudolf Cornelissen 	uint16		dest_left;				/* output reference, only the cliplist is displayed */
149e48ec1b5SRudolf Cornelissen 	uint16		dest_top;
150e48ec1b5SRudolf Cornelissen 	uint16		dest_width;				/* 0 to N, where zero means one */
151e48ec1b5SRudolf Cornelissen 										/* pixel, one means two pixels, etc. */
152e48ec1b5SRudolf Cornelissen 	uint16		dest_height;			/* 0 to M, where zero means one */
153e48ec1b5SRudolf Cornelissen 										/* line, one means two lines, etc. */
154e48ec1b5SRudolf Cornelissen 
155e48ec1b5SRudolf Cornelissen 	cliprect*	dest_cliplist;			/* rectangle(s) to draw in destination */
156e48ec1b5SRudolf Cornelissen 										/* guaranteed constrained to */
157e48ec1b5SRudolf Cornelissen 										/* virtual width and height */
158e48ec1b5SRudolf Cornelissen 	uint16		dest_clipcount;			/* number of rectangles to draw */
159e48ec1b5SRudolf Cornelissen } clipped_scaled_blit_params;
160e48ec1b5SRudolf Cornelissen 
16155ec61f4Sshatty status_t check_acc_capability(uint32 feature);
1625aa72126Sshatty status_t nv_acc_init(void);
1633c327b53SRudolf Cornelissen void nv_acc_assert_fifo(void);
1645aa72126Sshatty status_t nv_acc_setup_blit(void);
16555ec61f4Sshatty status_t nv_acc_blit(uint16,uint16,uint16, uint16,uint16,uint16 );
166b4c44701Sshatty status_t nv_acc_setup_rectangle(uint32 color);
167b4c44701Sshatty status_t nv_acc_rectangle(uint32 xs,uint32 xe,uint32 ys,uint32 yl);
1685aa72126Sshatty status_t nv_acc_setup_rect_invert(void);
169b4c44701Sshatty status_t nv_acc_rectangle_invert(uint32 xs,uint32 xe,uint32 ys,uint32 yl);
17055ec61f4Sshatty status_t nv_acc_transparent_blit(uint16,uint16,uint16, uint16,uint16,uint16, uint32);
17155ec61f4Sshatty status_t nv_acc_video_blit(uint16 xs,uint16 ys,uint16 ws, uint16 hs,
17255ec61f4Sshatty 	uint16 xd,uint16 yd,uint16 wd,uint16 hd);
1735aa72126Sshatty status_t nv_acc_wait_idle(void);
174dd43fd34SRudolf Cornelissen /* DMA versions */
1751554e5cbSRudolf Cornelissen status_t nv_acc_wait_idle_dma(void);
176dd43fd34SRudolf Cornelissen status_t nv_acc_init_dma(void);
17702e231b7SRudolf Cornelissen void nv_acc_assert_fifo_dma(void);
1781554e5cbSRudolf Cornelissen void SCREEN_TO_SCREEN_BLIT_DMA(engine_token *et, blit_params *list, uint32 count);
1791554e5cbSRudolf Cornelissen void SCREEN_TO_SCREEN_TRANSPARENT_BLIT_DMA(engine_token *et, uint32 transparent_colour, blit_params *list, uint32 count);
1801554e5cbSRudolf Cornelissen void SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT_DMA(engine_token *et, scaled_blit_params *list, uint32 count);
181e48ec1b5SRudolf Cornelissen void OFFSCREEN_TO_SCREEN_SCALED_FILTERED_BLIT_DMA(
182e48ec1b5SRudolf Cornelissen 	engine_token *et, offscreen_buffer_config *config, clipped_scaled_blit_params *list, uint32 count);
1831554e5cbSRudolf Cornelissen void FILL_RECTANGLE_DMA(engine_token *et, uint32 color, fill_rect_params *list, uint32 count);
1841554e5cbSRudolf Cornelissen void INVERT_RECTANGLE_DMA(engine_token *et, fill_rect_params *list, uint32 count);
1851554e5cbSRudolf Cornelissen void FILL_SPAN_DMA(engine_token *et, uint32 color, uint16 *list, uint32 count);
18655ec61f4Sshatty 
18755ec61f4Sshatty /* backend scaler functions */
18855ec61f4Sshatty status_t check_overlay_capability(uint32 feature);
189ac83e70cSRudolf Cornelissen void nv_bes_move_overlay(void);
19030f76422SRudolf Cornelissen status_t nv_bes_to_crtc(bool crtc);
1915aa72126Sshatty status_t nv_bes_init(void);
19255ec61f4Sshatty status_t nv_configure_bes
19355ec61f4Sshatty 	(const overlay_buffer *ob, const overlay_window *ow,const overlay_view *ov, int offset);
1945aa72126Sshatty status_t nv_release_bes(void);
19555ec61f4Sshatty 
19655ec61f4Sshatty /* driver structures and enums */
197e68c7d96SRudolf Cornelissen enum{BPP8 = 0, BPP15 = 1, BPP16 = 2, BPP24 = 3, BPP32 = 4};
198