.. | .. |
---|
53 | 53 | #include "sisusb.h" |
---|
54 | 54 | #include "sisusb_init.h" |
---|
55 | 55 | |
---|
56 | | -#ifdef INCL_SISUSB_CON |
---|
| 56 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
57 | 57 | #include <linux/font.h> |
---|
58 | 58 | #endif |
---|
59 | 59 | |
---|
.. | .. |
---|
61 | 61 | |
---|
62 | 62 | /* Forward declarations / clean-up routines */ |
---|
63 | 63 | |
---|
64 | | -#ifdef INCL_SISUSB_CON |
---|
| 64 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
65 | 65 | static int sisusb_first_vc; |
---|
66 | 66 | static int sisusb_last_vc; |
---|
67 | 67 | module_param_named(first, sisusb_first_vc, int, 0); |
---|
.. | .. |
---|
1198 | 1198 | |
---|
1199 | 1199 | /* High level: Gfx (indexed) register access */ |
---|
1200 | 1200 | |
---|
1201 | | -#ifdef INCL_SISUSB_CON |
---|
| 1201 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
1202 | 1202 | int sisusb_setreg(struct sisusb_usb_data *sisusb, u32 port, u8 data) |
---|
1203 | 1203 | { |
---|
1204 | 1204 | return sisusb_write_memio_byte(sisusb, SISUSB_TYPE_IO, port, data); |
---|
.. | .. |
---|
1272 | 1272 | |
---|
1273 | 1273 | /* Write/read video ram */ |
---|
1274 | 1274 | |
---|
1275 | | -#ifdef INCL_SISUSB_CON |
---|
| 1275 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
1276 | 1276 | int sisusb_writeb(struct sisusb_usb_data *sisusb, u32 adr, u8 data) |
---|
1277 | 1277 | { |
---|
1278 | 1278 | return sisusb_write_memio_byte(sisusb, SISUSB_TYPE_MEM, adr, data); |
---|
.. | .. |
---|
1283 | 1283 | return sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM, adr, data); |
---|
1284 | 1284 | } |
---|
1285 | 1285 | |
---|
1286 | | -int sisusb_copy_memory(struct sisusb_usb_data *sisusb, char *src, |
---|
| 1286 | +int sisusb_copy_memory(struct sisusb_usb_data *sisusb, u8 *src, |
---|
1287 | 1287 | u32 dest, int length) |
---|
1288 | 1288 | { |
---|
1289 | 1289 | size_t dummy; |
---|
.. | .. |
---|
1307 | 1307 | #ifdef SISUSBENDIANTEST |
---|
1308 | 1308 | static void sisusb_testreadwrite(struct sisusb_usb_data *sisusb) |
---|
1309 | 1309 | { |
---|
1310 | | - static char srcbuffer[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; |
---|
| 1310 | + static u8 srcbuffer[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; |
---|
1311 | 1311 | char destbuffer[10]; |
---|
1312 | 1312 | int i, j; |
---|
1313 | 1313 | |
---|
.. | .. |
---|
1747 | 1747 | return ret; |
---|
1748 | 1748 | } |
---|
1749 | 1749 | |
---|
1750 | | -static int sisusb_set_default_mode(struct sisusb_usb_data *sisusb, |
---|
| 1750 | +static void sisusb_set_default_mode(struct sisusb_usb_data *sisusb, |
---|
1751 | 1751 | int touchengines) |
---|
1752 | 1752 | { |
---|
1753 | | - int ret = 0, i, j, modex, bpp, du; |
---|
| 1753 | + int i, j, modex, bpp, du; |
---|
1754 | 1754 | u8 sr31, cr63, tmp8; |
---|
1755 | 1755 | static const char attrdata[] = { |
---|
1756 | 1756 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
---|
.. | .. |
---|
1873 | 1873 | } |
---|
1874 | 1874 | |
---|
1875 | 1875 | SETIREG(SISCR, 0x34, 0x44); /* we just set std mode #44 */ |
---|
1876 | | - |
---|
1877 | | - return ret; |
---|
1878 | 1876 | } |
---|
1879 | 1877 | |
---|
1880 | 1878 | static int sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) |
---|
.. | .. |
---|
2019 | 2017 | |
---|
2020 | 2018 | ret |= SETIREG(SISCR, 0x83, 0x00); |
---|
2021 | 2019 | |
---|
2022 | | - ret |= sisusb_set_default_mode(sisusb, 0); |
---|
| 2020 | + sisusb_set_default_mode(sisusb, 0); |
---|
2023 | 2021 | |
---|
2024 | 2022 | ret |= SETIREGAND(SISSR, 0x21, 0xdf); |
---|
2025 | 2023 | ret |= SETIREGOR(SISSR, 0x01, 0x20); |
---|
.. | .. |
---|
2246 | 2244 | if (sisusb_init_gfxcore(sisusb) == 0) { |
---|
2247 | 2245 | sisusb->gfxinit = 1; |
---|
2248 | 2246 | sisusb_get_ramconfig(sisusb); |
---|
2249 | | - ret |= sisusb_set_default_mode(sisusb, 1); |
---|
| 2247 | + sisusb_set_default_mode(sisusb, 1); |
---|
2250 | 2248 | ret |= sisusb_setup_screen(sisusb, 1, initscreen); |
---|
2251 | 2249 | } |
---|
2252 | 2250 | } |
---|
.. | .. |
---|
2255 | 2253 | } |
---|
2256 | 2254 | |
---|
2257 | 2255 | |
---|
2258 | | -#ifdef INCL_SISUSB_CON |
---|
| 2256 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
2259 | 2257 | |
---|
2260 | 2258 | /* Set up default text mode: |
---|
2261 | 2259 | * - Set text mode (0x03) |
---|
.. | .. |
---|
2342 | 2340 | } |
---|
2343 | 2341 | |
---|
2344 | 2342 | } else if (sisusb->scrbuf) { |
---|
2345 | | - ret |= sisusb_copy_memory(sisusb, (char *)sisusb->scrbuf, |
---|
| 2343 | + ret |= sisusb_copy_memory(sisusb, (u8 *)sisusb->scrbuf, |
---|
2346 | 2344 | sisusb->vrambase, sisusb->scrbuf_size); |
---|
2347 | 2345 | } |
---|
2348 | 2346 | |
---|
.. | .. |
---|
2448 | 2446 | sisusb->sisusb_dev = NULL; |
---|
2449 | 2447 | sisusb_free_buffers(sisusb); |
---|
2450 | 2448 | sisusb_free_urbs(sisusb); |
---|
2451 | | -#ifdef INCL_SISUSB_CON |
---|
| 2449 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
2452 | 2450 | kfree(sisusb->SiS_Pr); |
---|
2453 | 2451 | #endif |
---|
2454 | 2452 | kfree(sisusb); |
---|
.. | .. |
---|
2844 | 2842 | |
---|
2845 | 2843 | case SUCMD_HANDLETEXTMODE: |
---|
2846 | 2844 | retval = 0; |
---|
2847 | | -#ifdef INCL_SISUSB_CON |
---|
| 2845 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
2848 | 2846 | /* Gfx core must be initialized, SiS_Pr must exist */ |
---|
2849 | 2847 | if (!sisusb->gfxinit || !sisusb->SiS_Pr) |
---|
2850 | 2848 | return -ENODEV; |
---|
.. | .. |
---|
2860 | 2858 | #endif |
---|
2861 | 2859 | break; |
---|
2862 | 2860 | |
---|
2863 | | -#ifdef INCL_SISUSB_CON |
---|
| 2861 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
2864 | 2862 | case SUCMD_SETMODE: |
---|
2865 | 2863 | /* Gfx core must be initialized, SiS_Pr must exist */ |
---|
2866 | 2864 | if (!sisusb->gfxinit || !sisusb->SiS_Pr) |
---|
.. | .. |
---|
2944 | 2942 | x.sisusb_vramsize = sisusb->vramsize; |
---|
2945 | 2943 | x.sisusb_minor = sisusb->minor; |
---|
2946 | 2944 | x.sisusb_fbdevactive = 0; |
---|
2947 | | -#ifdef INCL_SISUSB_CON |
---|
| 2945 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
2948 | 2946 | x.sisusb_conactive = sisusb->haveconsole ? 1 : 0; |
---|
2949 | 2947 | #else |
---|
2950 | 2948 | x.sisusb_conactive = 0; |
---|
.. | .. |
---|
2975 | 2973 | return retval; |
---|
2976 | 2974 | } |
---|
2977 | 2975 | |
---|
2978 | | -#ifdef SISUSB_NEW_CONFIG_COMPAT |
---|
| 2976 | +#ifdef CONFIG_COMPAT |
---|
2979 | 2977 | static long sisusb_compat_ioctl(struct file *f, unsigned int cmd, |
---|
2980 | 2978 | unsigned long arg) |
---|
2981 | 2979 | { |
---|
.. | .. |
---|
2998 | 2996 | .read = sisusb_read, |
---|
2999 | 2997 | .write = sisusb_write, |
---|
3000 | 2998 | .llseek = sisusb_lseek, |
---|
3001 | | -#ifdef SISUSB_NEW_CONFIG_COMPAT |
---|
| 2999 | +#ifdef CONFIG_COMPAT |
---|
3002 | 3000 | .compat_ioctl = sisusb_compat_ioctl, |
---|
3003 | 3001 | #endif |
---|
3004 | 3002 | .unlocked_ioctl = sisusb_ioctl |
---|
.. | .. |
---|
3016 | 3014 | struct usb_device *dev = interface_to_usbdev(intf); |
---|
3017 | 3015 | struct sisusb_usb_data *sisusb; |
---|
3018 | 3016 | int retval = 0, i; |
---|
| 3017 | + static const u8 ep_addresses[] = { |
---|
| 3018 | + SISUSB_EP_GFX_IN | USB_DIR_IN, |
---|
| 3019 | + SISUSB_EP_GFX_OUT | USB_DIR_OUT, |
---|
| 3020 | + SISUSB_EP_GFX_BULK_OUT | USB_DIR_OUT, |
---|
| 3021 | + SISUSB_EP_GFX_LBULK_OUT | USB_DIR_OUT, |
---|
| 3022 | + SISUSB_EP_BRIDGE_IN | USB_DIR_IN, |
---|
| 3023 | + SISUSB_EP_BRIDGE_OUT | USB_DIR_OUT, |
---|
| 3024 | + 0}; |
---|
| 3025 | + |
---|
| 3026 | + /* Are the expected endpoints present? */ |
---|
| 3027 | + if (!usb_check_bulk_endpoints(intf, ep_addresses)) { |
---|
| 3028 | + dev_err(&intf->dev, "Invalid USB2VGA device\n"); |
---|
| 3029 | + return -EINVAL; |
---|
| 3030 | + } |
---|
3019 | 3031 | |
---|
3020 | 3032 | dev_info(&dev->dev, "USB2VGA dongle found at address %d\n", |
---|
3021 | 3033 | dev->devnum); |
---|
.. | .. |
---|
3092 | 3104 | dev_info(&sisusb->sisusb_dev->dev, "Allocated %d output buffers\n", |
---|
3093 | 3105 | sisusb->numobufs); |
---|
3094 | 3106 | |
---|
3095 | | -#ifdef INCL_SISUSB_CON |
---|
| 3107 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
3096 | 3108 | /* Allocate our SiS_Pr */ |
---|
3097 | 3109 | sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL); |
---|
3098 | 3110 | if (!sisusb->SiS_Pr) { |
---|
.. | .. |
---|
3113 | 3125 | |
---|
3114 | 3126 | if (dev->speed == USB_SPEED_HIGH || dev->speed >= USB_SPEED_SUPER) { |
---|
3115 | 3127 | int initscreen = 1; |
---|
3116 | | -#ifdef INCL_SISUSB_CON |
---|
| 3128 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
3117 | 3129 | if (sisusb_first_vc > 0 && sisusb_last_vc > 0 && |
---|
3118 | 3130 | sisusb_first_vc <= sisusb_last_vc && |
---|
3119 | 3131 | sisusb_last_vc <= MAX_NR_CONSOLES) |
---|
.. | .. |
---|
3135 | 3147 | dev_dbg(&sisusb->sisusb_dev->dev, "*** RWTEST END ***\n"); |
---|
3136 | 3148 | #endif |
---|
3137 | 3149 | |
---|
3138 | | -#ifdef INCL_SISUSB_CON |
---|
| 3150 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
3139 | 3151 | sisusb_console_init(sisusb, sisusb_first_vc, sisusb_last_vc); |
---|
3140 | 3152 | #endif |
---|
3141 | 3153 | |
---|
.. | .. |
---|
3161 | 3173 | if (!sisusb) |
---|
3162 | 3174 | return; |
---|
3163 | 3175 | |
---|
3164 | | -#ifdef INCL_SISUSB_CON |
---|
| 3176 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
3165 | 3177 | sisusb_console_exit(sisusb); |
---|
3166 | 3178 | #endif |
---|
3167 | 3179 | |
---|
.. | .. |
---|
3211 | 3223 | static int __init usb_sisusb_init(void) |
---|
3212 | 3224 | { |
---|
3213 | 3225 | |
---|
3214 | | -#ifdef INCL_SISUSB_CON |
---|
| 3226 | +#ifdef CONFIG_USB_SISUSBVGA_CON |
---|
3215 | 3227 | sisusb_init_concode(); |
---|
3216 | 3228 | #endif |
---|
3217 | 3229 | |
---|