18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
48c2ecf20Sopenharmony_ci * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __IOCTL_H__
98c2ecf20Sopenharmony_ci#define __IOCTL_H__
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef __user
128c2ecf20Sopenharmony_ci#define __user
138c2ecf20Sopenharmony_ci#endif
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/* VIAFB IOCTL definition */
168c2ecf20Sopenharmony_ci#define VIAFB_GET_INFO_SIZE		0x56494101	/* 'VIA\01' */
178c2ecf20Sopenharmony_ci#define VIAFB_GET_INFO			0x56494102	/* 'VIA\02' */
188c2ecf20Sopenharmony_ci#define VIAFB_HOTPLUG			0x56494103	/* 'VIA\03' */
198c2ecf20Sopenharmony_ci#define VIAFB_SET_HOTPLUG_FLAG		0x56494104	/* 'VIA\04' */
208c2ecf20Sopenharmony_ci#define VIAFB_GET_RESOLUTION		0x56494105	/* 'VIA\05' */
218c2ecf20Sopenharmony_ci#define VIAFB_GET_SAMM_INFO		0x56494107	/* 'VIA\07' */
228c2ecf20Sopenharmony_ci#define VIAFB_TURN_ON_OUTPUT_DEVICE     0x56494108	/* 'VIA\08' */
238c2ecf20Sopenharmony_ci#define VIAFB_TURN_OFF_OUTPUT_DEVICE    0x56494109	/* 'VIA\09' */
248c2ecf20Sopenharmony_ci#define VIAFB_GET_DEVICE		0x5649410B
258c2ecf20Sopenharmony_ci#define VIAFB_GET_DRIVER_VERSION	0x56494112	/* 'VIA\12' */
268c2ecf20Sopenharmony_ci#define VIAFB_GET_CHIP_INFO		0x56494113	/* 'VIA\13' */
278c2ecf20Sopenharmony_ci#define VIAFB_GET_DEVICE_INFO           0x56494115
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define VIAFB_GET_DEVICE_SUPPORT	0x56494118
308c2ecf20Sopenharmony_ci#define VIAFB_GET_DEVICE_CONNECT	0x56494119
318c2ecf20Sopenharmony_ci#define VIAFB_GET_PANEL_SUPPORT_EXPAND	0x5649411A
328c2ecf20Sopenharmony_ci#define VIAFB_GET_DRIVER_NAME		0x56494122
338c2ecf20Sopenharmony_ci#define VIAFB_GET_DEVICE_SUPPORT_STATE	0x56494123
348c2ecf20Sopenharmony_ci#define VIAFB_GET_GAMMA_LUT		0x56494124
358c2ecf20Sopenharmony_ci#define VIAFB_SET_GAMMA_LUT		0x56494125
368c2ecf20Sopenharmony_ci#define VIAFB_GET_GAMMA_SUPPORT_STATE	0x56494126
378c2ecf20Sopenharmony_ci#define VIAFB_SYNC_SURFACE		0x56494130
388c2ecf20Sopenharmony_ci#define VIAFB_GET_DRIVER_CAPS		0x56494131
398c2ecf20Sopenharmony_ci#define VIAFB_GET_IGA_SCALING_INFO	0x56494132
408c2ecf20Sopenharmony_ci#define VIAFB_GET_PANEL_MAX_SIZE	0x56494133
418c2ecf20Sopenharmony_ci#define VIAFB_GET_PANEL_MAX_POSITION	0x56494134
428c2ecf20Sopenharmony_ci#define VIAFB_SET_PANEL_SIZE		0x56494135
438c2ecf20Sopenharmony_ci#define VIAFB_SET_PANEL_POSITION        0x56494136
448c2ecf20Sopenharmony_ci#define VIAFB_GET_PANEL_POSITION        0x56494137
458c2ecf20Sopenharmony_ci#define VIAFB_GET_PANEL_SIZE		0x56494138
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define None_Device 0x00
488c2ecf20Sopenharmony_ci#define CRT_Device  0x01
498c2ecf20Sopenharmony_ci#define LCD_Device  0x02
508c2ecf20Sopenharmony_ci#define DVI_Device  0x08
518c2ecf20Sopenharmony_ci#define CRT2_Device 0x10
528c2ecf20Sopenharmony_ci#define LCD2_Device 0x40
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define OP_LCD_CENTERING   0x01
558c2ecf20Sopenharmony_ci#define OP_LCD_PANEL_ID    0x02
568c2ecf20Sopenharmony_ci#define OP_LCD_MODE        0x03
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/*SAMM operation flag*/
598c2ecf20Sopenharmony_ci#define OP_SAMM            0x80
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define LCD_PANEL_ID_MAXIMUM	23
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define STATE_ON            0x1
648c2ecf20Sopenharmony_ci#define STATE_OFF           0x0
658c2ecf20Sopenharmony_ci#define STATE_DEFAULT       0xFFFF
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define MAX_ACTIVE_DEV_NUM  2
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistruct device_t {
708c2ecf20Sopenharmony_ci	unsigned short crt:1;
718c2ecf20Sopenharmony_ci	unsigned short dvi:1;
728c2ecf20Sopenharmony_ci	unsigned short lcd:1;
738c2ecf20Sopenharmony_ci	unsigned short samm:1;
748c2ecf20Sopenharmony_ci	unsigned short lcd_dsp_cent:1;
758c2ecf20Sopenharmony_ci	unsigned char lcd_mode:1;
768c2ecf20Sopenharmony_ci	unsigned short epia_dvi:1;
778c2ecf20Sopenharmony_ci	unsigned short lcd_dual_edge:1;
788c2ecf20Sopenharmony_ci	unsigned short lcd2:1;
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	unsigned short primary_dev;
818c2ecf20Sopenharmony_ci	unsigned char lcd_panel_id;
828c2ecf20Sopenharmony_ci	unsigned short xres, yres;
838c2ecf20Sopenharmony_ci	unsigned short xres1, yres1;
848c2ecf20Sopenharmony_ci	unsigned short refresh;
858c2ecf20Sopenharmony_ci	unsigned short bpp;
868c2ecf20Sopenharmony_ci	unsigned short refresh1;
878c2ecf20Sopenharmony_ci	unsigned short bpp1;
888c2ecf20Sopenharmony_ci	unsigned short sequence;
898c2ecf20Sopenharmony_ci	unsigned short bus_width;
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cistruct viafb_ioctl_info {
938c2ecf20Sopenharmony_ci	u32 viafb_id;		/* for identifying viafb */
948c2ecf20Sopenharmony_ci#define VIAID       0x56494146	/* Identify myself with 'VIAF' */
958c2ecf20Sopenharmony_ci	u16 vendor_id;
968c2ecf20Sopenharmony_ci	u16 device_id;
978c2ecf20Sopenharmony_ci	u8 version;
988c2ecf20Sopenharmony_ci	u8 revision;
998c2ecf20Sopenharmony_ci	u8 reserved[246];	/* for future use */
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistruct viafb_ioctl_mode {
1038c2ecf20Sopenharmony_ci	u32 xres;
1048c2ecf20Sopenharmony_ci	u32 yres;
1058c2ecf20Sopenharmony_ci	u32 refresh;
1068c2ecf20Sopenharmony_ci	u32 bpp;
1078c2ecf20Sopenharmony_ci	u32 xres_sec;
1088c2ecf20Sopenharmony_ci	u32 yres_sec;
1098c2ecf20Sopenharmony_ci	u32 virtual_xres_sec;
1108c2ecf20Sopenharmony_ci	u32 virtual_yres_sec;
1118c2ecf20Sopenharmony_ci	u32 refresh_sec;
1128c2ecf20Sopenharmony_ci	u32 bpp_sec;
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_cistruct viafb_ioctl_samm {
1158c2ecf20Sopenharmony_ci	u32 samm_status;
1168c2ecf20Sopenharmony_ci	u32 size_prim;
1178c2ecf20Sopenharmony_ci	u32 size_sec;
1188c2ecf20Sopenharmony_ci	u32 mem_base;
1198c2ecf20Sopenharmony_ci	u32 offset_sec;
1208c2ecf20Sopenharmony_ci};
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_cistruct viafb_driver_version {
1238c2ecf20Sopenharmony_ci	int iMajorNum;
1248c2ecf20Sopenharmony_ci	int iKernelNum;
1258c2ecf20Sopenharmony_ci	int iOSNum;
1268c2ecf20Sopenharmony_ci	int iMinorNum;
1278c2ecf20Sopenharmony_ci};
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_cistruct viafb_ioctl_lcd_attribute {
1308c2ecf20Sopenharmony_ci	unsigned int panel_id;
1318c2ecf20Sopenharmony_ci	unsigned int display_center;
1328c2ecf20Sopenharmony_ci	unsigned int lcd_mode;
1338c2ecf20Sopenharmony_ci};
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_cistruct viafb_ioctl_setting {
1368c2ecf20Sopenharmony_ci	/* Enable or disable active devices */
1378c2ecf20Sopenharmony_ci	unsigned short device_flag;
1388c2ecf20Sopenharmony_ci	/* Indicate which device should be turn on or turn off. */
1398c2ecf20Sopenharmony_ci	unsigned short device_status;
1408c2ecf20Sopenharmony_ci	unsigned int reserved;
1418c2ecf20Sopenharmony_ci	/* Indicate which LCD's attribute can be changed. */
1428c2ecf20Sopenharmony_ci	unsigned short lcd_operation_flag;
1438c2ecf20Sopenharmony_ci	/* 1: SAMM ON  0: SAMM OFF */
1448c2ecf20Sopenharmony_ci	unsigned short samm_status;
1458c2ecf20Sopenharmony_ci	/* horizontal resolution of first device */
1468c2ecf20Sopenharmony_ci	unsigned short first_dev_hor_res;
1478c2ecf20Sopenharmony_ci	/* vertical resolution of first device */
1488c2ecf20Sopenharmony_ci	unsigned short first_dev_ver_res;
1498c2ecf20Sopenharmony_ci	/* horizontal resolution of second device */
1508c2ecf20Sopenharmony_ci	unsigned short second_dev_hor_res;
1518c2ecf20Sopenharmony_ci	/* vertical resolution of second device */
1528c2ecf20Sopenharmony_ci	unsigned short second_dev_ver_res;
1538c2ecf20Sopenharmony_ci	/* refresh rate of first device */
1548c2ecf20Sopenharmony_ci	unsigned short first_dev_refresh;
1558c2ecf20Sopenharmony_ci	/* bpp of first device */
1568c2ecf20Sopenharmony_ci	unsigned short first_dev_bpp;
1578c2ecf20Sopenharmony_ci	/* refresh rate of second device */
1588c2ecf20Sopenharmony_ci	unsigned short second_dev_refresh;
1598c2ecf20Sopenharmony_ci	/* bpp of second device */
1608c2ecf20Sopenharmony_ci	unsigned short second_dev_bpp;
1618c2ecf20Sopenharmony_ci	/* Indicate which device are primary display device. */
1628c2ecf20Sopenharmony_ci	unsigned int primary_device;
1638c2ecf20Sopenharmony_ci	unsigned int struct_reserved[35];
1648c2ecf20Sopenharmony_ci	struct viafb_ioctl_lcd_attribute lcd_attributes;
1658c2ecf20Sopenharmony_ci};
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_cistruct _UTFunctionCaps {
1688c2ecf20Sopenharmony_ci	unsigned int dw3DScalingState;
1698c2ecf20Sopenharmony_ci	unsigned int reserved[31];
1708c2ecf20Sopenharmony_ci};
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_cistruct _POSITIONVALUE {
1738c2ecf20Sopenharmony_ci	unsigned int dwX;
1748c2ecf20Sopenharmony_ci	unsigned int dwY;
1758c2ecf20Sopenharmony_ci};
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cistruct _panel_size_pos_info {
1788c2ecf20Sopenharmony_ci	unsigned int device_type;
1798c2ecf20Sopenharmony_ci	int x;
1808c2ecf20Sopenharmony_ci	int y;
1818c2ecf20Sopenharmony_ci};
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ciextern int viafb_LCD_ON;
1848c2ecf20Sopenharmony_ciextern int viafb_DVI_ON;
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ciint viafb_ioctl_get_viafb_info(u_long arg);
1878c2ecf20Sopenharmony_ciint viafb_ioctl_hotplug(int hres, int vres, int bpp);
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci#endif /* __IOCTL_H__ */
190