xref: /linux/drivers/video/fbdev/via/ioctl.c (revision 56fb34d86e875dbb0d3e6a81c5d3d035db373031)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
4  * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
5 
6  */
7 
8 #include "global.h"
9 
10 int viafb_ioctl_get_viafb_info(u_long arg)
11 {
12 	struct viafb_ioctl_info viainfo;
13 
14 	memset(&viainfo, 0, sizeof(struct viafb_ioctl_info));
15 
16 	viainfo.viafb_id = VIAID;
17 	viainfo.vendor_id = PCI_VIA_VENDOR_ID;
18 
19 	switch (viaparinfo->chip_info->gfx_chip_name) {
20 	case UNICHROME_CLE266:
21 		viainfo.device_id = UNICHROME_CLE266_DID;
22 		break;
23 
24 	case UNICHROME_K400:
25 		viainfo.device_id = UNICHROME_K400_DID;
26 		break;
27 
28 	case UNICHROME_K800:
29 		viainfo.device_id = UNICHROME_K800_DID;
30 		break;
31 
32 	case UNICHROME_PM800:
33 		viainfo.device_id = UNICHROME_PM800_DID;
34 		break;
35 
36 	case UNICHROME_CN700:
37 		viainfo.device_id = UNICHROME_CN700_DID;
38 		break;
39 
40 	case UNICHROME_CX700:
41 		viainfo.device_id = UNICHROME_CX700_DID;
42 		break;
43 
44 	case UNICHROME_K8M890:
45 		viainfo.device_id = UNICHROME_K8M890_DID;
46 		break;
47 
48 	case UNICHROME_P4M890:
49 		viainfo.device_id = UNICHROME_P4M890_DID;
50 		break;
51 
52 	case UNICHROME_P4M900:
53 		viainfo.device_id = UNICHROME_P4M900_DID;
54 		break;
55 	}
56 
57 	viainfo.version = VERSION_MAJOR;
58 	viainfo.revision = VERSION_MINOR;
59 
60 	if (copy_to_user((void __user *)arg, &viainfo, sizeof(viainfo)))
61 		return -EFAULT;
62 
63 	return 0;
64 }
65 
66 /* Hot-Plug Priority: DVI > CRT*/
67 int viafb_ioctl_hotplug(int hres, int vres, int bpp)
68 {
69 	int DVIsense, status = 0;
70 	DEBUG_MSG(KERN_INFO "viafb_ioctl_hotplug!!\n");
71 
72 	if (viaparinfo->chip_info->tmds_chip_info.tmds_chip_name !=
73 		NON_TMDS_TRANSMITTER) {
74 		DVIsense = viafb_dvi_sense();
75 
76 		if (DVIsense) {
77 			DEBUG_MSG(KERN_INFO "DVI Attached...\n");
78 			if (viafb_DeviceStatus != DVI_Device) {
79 				viafb_DVI_ON = 1;
80 				viafb_CRT_ON = 0;
81 				viafb_LCD_ON = 0;
82 				viafb_DeviceStatus = DVI_Device;
83 				viafb_set_iga_path();
84 				return viafb_DeviceStatus;
85 			}
86 			status = 1;
87 		} else
88 			DEBUG_MSG(KERN_INFO "DVI De-attached...\n");
89 	}
90 
91 	if ((viafb_DeviceStatus != CRT_Device) && (status == 0)) {
92 		viafb_CRT_ON = 1;
93 		viafb_DVI_ON = 0;
94 		viafb_LCD_ON = 0;
95 
96 		viafb_DeviceStatus = CRT_Device;
97 		viafb_set_iga_path();
98 		return viafb_DeviceStatus;
99 	}
100 
101 	return 0;
102 }
103