162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
462306a36Sopenharmony_ci * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef __IOCTL_H__
962306a36Sopenharmony_ci#define __IOCTL_H__
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#ifndef __user
1262306a36Sopenharmony_ci#define __user
1362306a36Sopenharmony_ci#endif
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/* VIAFB IOCTL definition */
1662306a36Sopenharmony_ci#define VIAFB_GET_INFO_SIZE		0x56494101	/* 'VIA\01' */
1762306a36Sopenharmony_ci#define VIAFB_GET_INFO			0x56494102	/* 'VIA\02' */
1862306a36Sopenharmony_ci#define VIAFB_HOTPLUG			0x56494103	/* 'VIA\03' */
1962306a36Sopenharmony_ci#define VIAFB_SET_HOTPLUG_FLAG		0x56494104	/* 'VIA\04' */
2062306a36Sopenharmony_ci#define VIAFB_GET_RESOLUTION		0x56494105	/* 'VIA\05' */
2162306a36Sopenharmony_ci#define VIAFB_GET_SAMM_INFO		0x56494107	/* 'VIA\07' */
2262306a36Sopenharmony_ci#define VIAFB_TURN_ON_OUTPUT_DEVICE     0x56494108	/* 'VIA\08' */
2362306a36Sopenharmony_ci#define VIAFB_TURN_OFF_OUTPUT_DEVICE    0x56494109	/* 'VIA\09' */
2462306a36Sopenharmony_ci#define VIAFB_GET_DEVICE		0x5649410B
2562306a36Sopenharmony_ci#define VIAFB_GET_DRIVER_VERSION	0x56494112	/* 'VIA\12' */
2662306a36Sopenharmony_ci#define VIAFB_GET_CHIP_INFO		0x56494113	/* 'VIA\13' */
2762306a36Sopenharmony_ci#define VIAFB_GET_DEVICE_INFO           0x56494115
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#define VIAFB_GET_DEVICE_SUPPORT	0x56494118
3062306a36Sopenharmony_ci#define VIAFB_GET_DEVICE_CONNECT	0x56494119
3162306a36Sopenharmony_ci#define VIAFB_GET_PANEL_SUPPORT_EXPAND	0x5649411A
3262306a36Sopenharmony_ci#define VIAFB_GET_DRIVER_NAME		0x56494122
3362306a36Sopenharmony_ci#define VIAFB_GET_DEVICE_SUPPORT_STATE	0x56494123
3462306a36Sopenharmony_ci#define VIAFB_GET_GAMMA_LUT		0x56494124
3562306a36Sopenharmony_ci#define VIAFB_SET_GAMMA_LUT		0x56494125
3662306a36Sopenharmony_ci#define VIAFB_GET_GAMMA_SUPPORT_STATE	0x56494126
3762306a36Sopenharmony_ci#define VIAFB_SYNC_SURFACE		0x56494130
3862306a36Sopenharmony_ci#define VIAFB_GET_DRIVER_CAPS		0x56494131
3962306a36Sopenharmony_ci#define VIAFB_GET_IGA_SCALING_INFO	0x56494132
4062306a36Sopenharmony_ci#define VIAFB_GET_PANEL_MAX_SIZE	0x56494133
4162306a36Sopenharmony_ci#define VIAFB_GET_PANEL_MAX_POSITION	0x56494134
4262306a36Sopenharmony_ci#define VIAFB_SET_PANEL_SIZE		0x56494135
4362306a36Sopenharmony_ci#define VIAFB_SET_PANEL_POSITION        0x56494136
4462306a36Sopenharmony_ci#define VIAFB_GET_PANEL_POSITION        0x56494137
4562306a36Sopenharmony_ci#define VIAFB_GET_PANEL_SIZE		0x56494138
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci#define None_Device 0x00
4862306a36Sopenharmony_ci#define CRT_Device  0x01
4962306a36Sopenharmony_ci#define LCD_Device  0x02
5062306a36Sopenharmony_ci#define DVI_Device  0x08
5162306a36Sopenharmony_ci#define CRT2_Device 0x10
5262306a36Sopenharmony_ci#define LCD2_Device 0x40
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define OP_LCD_CENTERING   0x01
5562306a36Sopenharmony_ci#define OP_LCD_PANEL_ID    0x02
5662306a36Sopenharmony_ci#define OP_LCD_MODE        0x03
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/*SAMM operation flag*/
5962306a36Sopenharmony_ci#define OP_SAMM            0x80
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#define LCD_PANEL_ID_MAXIMUM	23
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define STATE_ON            0x1
6462306a36Sopenharmony_ci#define STATE_OFF           0x0
6562306a36Sopenharmony_ci#define STATE_DEFAULT       0xFFFF
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define MAX_ACTIVE_DEV_NUM  2
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_cistruct device_t {
7062306a36Sopenharmony_ci	unsigned short crt:1;
7162306a36Sopenharmony_ci	unsigned short dvi:1;
7262306a36Sopenharmony_ci	unsigned short lcd:1;
7362306a36Sopenharmony_ci	unsigned short samm:1;
7462306a36Sopenharmony_ci	unsigned short lcd_dsp_cent:1;
7562306a36Sopenharmony_ci	unsigned char lcd_mode:1;
7662306a36Sopenharmony_ci	unsigned short epia_dvi:1;
7762306a36Sopenharmony_ci	unsigned short lcd_dual_edge:1;
7862306a36Sopenharmony_ci	unsigned short lcd2:1;
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci	unsigned short primary_dev;
8162306a36Sopenharmony_ci	unsigned char lcd_panel_id;
8262306a36Sopenharmony_ci	unsigned short xres, yres;
8362306a36Sopenharmony_ci	unsigned short xres1, yres1;
8462306a36Sopenharmony_ci	unsigned short refresh;
8562306a36Sopenharmony_ci	unsigned short bpp;
8662306a36Sopenharmony_ci	unsigned short refresh1;
8762306a36Sopenharmony_ci	unsigned short bpp1;
8862306a36Sopenharmony_ci	unsigned short sequence;
8962306a36Sopenharmony_ci	unsigned short bus_width;
9062306a36Sopenharmony_ci};
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_cistruct viafb_ioctl_info {
9362306a36Sopenharmony_ci	u32 viafb_id;		/* for identifying viafb */
9462306a36Sopenharmony_ci#define VIAID       0x56494146	/* Identify myself with 'VIAF' */
9562306a36Sopenharmony_ci	u16 vendor_id;
9662306a36Sopenharmony_ci	u16 device_id;
9762306a36Sopenharmony_ci	u8 version;
9862306a36Sopenharmony_ci	u8 revision;
9962306a36Sopenharmony_ci	u8 reserved[246];	/* for future use */
10062306a36Sopenharmony_ci};
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_cistruct viafb_ioctl_mode {
10362306a36Sopenharmony_ci	u32 xres;
10462306a36Sopenharmony_ci	u32 yres;
10562306a36Sopenharmony_ci	u32 refresh;
10662306a36Sopenharmony_ci	u32 bpp;
10762306a36Sopenharmony_ci	u32 xres_sec;
10862306a36Sopenharmony_ci	u32 yres_sec;
10962306a36Sopenharmony_ci	u32 virtual_xres_sec;
11062306a36Sopenharmony_ci	u32 virtual_yres_sec;
11162306a36Sopenharmony_ci	u32 refresh_sec;
11262306a36Sopenharmony_ci	u32 bpp_sec;
11362306a36Sopenharmony_ci};
11462306a36Sopenharmony_cistruct viafb_ioctl_samm {
11562306a36Sopenharmony_ci	u32 samm_status;
11662306a36Sopenharmony_ci	u32 size_prim;
11762306a36Sopenharmony_ci	u32 size_sec;
11862306a36Sopenharmony_ci	u32 mem_base;
11962306a36Sopenharmony_ci	u32 offset_sec;
12062306a36Sopenharmony_ci};
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_cistruct viafb_driver_version {
12362306a36Sopenharmony_ci	int iMajorNum;
12462306a36Sopenharmony_ci	int iKernelNum;
12562306a36Sopenharmony_ci	int iOSNum;
12662306a36Sopenharmony_ci	int iMinorNum;
12762306a36Sopenharmony_ci};
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_cistruct viafb_ioctl_lcd_attribute {
13062306a36Sopenharmony_ci	unsigned int panel_id;
13162306a36Sopenharmony_ci	unsigned int display_center;
13262306a36Sopenharmony_ci	unsigned int lcd_mode;
13362306a36Sopenharmony_ci};
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_cistruct viafb_ioctl_setting {
13662306a36Sopenharmony_ci	/* Enable or disable active devices */
13762306a36Sopenharmony_ci	unsigned short device_flag;
13862306a36Sopenharmony_ci	/* Indicate which device should be turn on or turn off. */
13962306a36Sopenharmony_ci	unsigned short device_status;
14062306a36Sopenharmony_ci	unsigned int reserved;
14162306a36Sopenharmony_ci	/* Indicate which LCD's attribute can be changed. */
14262306a36Sopenharmony_ci	unsigned short lcd_operation_flag;
14362306a36Sopenharmony_ci	/* 1: SAMM ON  0: SAMM OFF */
14462306a36Sopenharmony_ci	unsigned short samm_status;
14562306a36Sopenharmony_ci	/* horizontal resolution of first device */
14662306a36Sopenharmony_ci	unsigned short first_dev_hor_res;
14762306a36Sopenharmony_ci	/* vertical resolution of first device */
14862306a36Sopenharmony_ci	unsigned short first_dev_ver_res;
14962306a36Sopenharmony_ci	/* horizontal resolution of second device */
15062306a36Sopenharmony_ci	unsigned short second_dev_hor_res;
15162306a36Sopenharmony_ci	/* vertical resolution of second device */
15262306a36Sopenharmony_ci	unsigned short second_dev_ver_res;
15362306a36Sopenharmony_ci	/* refresh rate of first device */
15462306a36Sopenharmony_ci	unsigned short first_dev_refresh;
15562306a36Sopenharmony_ci	/* bpp of first device */
15662306a36Sopenharmony_ci	unsigned short first_dev_bpp;
15762306a36Sopenharmony_ci	/* refresh rate of second device */
15862306a36Sopenharmony_ci	unsigned short second_dev_refresh;
15962306a36Sopenharmony_ci	/* bpp of second device */
16062306a36Sopenharmony_ci	unsigned short second_dev_bpp;
16162306a36Sopenharmony_ci	/* Indicate which device are primary display device. */
16262306a36Sopenharmony_ci	unsigned int primary_device;
16362306a36Sopenharmony_ci	unsigned int struct_reserved[35];
16462306a36Sopenharmony_ci	struct viafb_ioctl_lcd_attribute lcd_attributes;
16562306a36Sopenharmony_ci};
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_cistruct _UTFunctionCaps {
16862306a36Sopenharmony_ci	unsigned int dw3DScalingState;
16962306a36Sopenharmony_ci	unsigned int reserved[31];
17062306a36Sopenharmony_ci};
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_cistruct _POSITIONVALUE {
17362306a36Sopenharmony_ci	unsigned int dwX;
17462306a36Sopenharmony_ci	unsigned int dwY;
17562306a36Sopenharmony_ci};
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_cistruct _panel_size_pos_info {
17862306a36Sopenharmony_ci	unsigned int device_type;
17962306a36Sopenharmony_ci	int x;
18062306a36Sopenharmony_ci	int y;
18162306a36Sopenharmony_ci};
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ciextern int viafb_LCD_ON;
18462306a36Sopenharmony_ciextern int viafb_DVI_ON;
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ciint viafb_ioctl_get_viafb_info(u_long arg);
18762306a36Sopenharmony_ciint viafb_ioctl_hotplug(int hres, int vres, int bpp);
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci#endif /* __IOCTL_H__ */
190