panel.c (718e05ed92ecac0d9d3954bcc8064527c3ce7565) | panel.c (2545c1c948a6a765f1a0e820c7598138b36f67ef) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Front panel driver for Linux 4 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu> 5 * Copyright (C) 2016-2017 Glider bvba 6 * 7 * This code drives an LCD module (/dev/lcd), and a keypad (/dev/keypad) 8 * connected to a parallel printer port. --- 285 unchanged lines hidden (view full) --- 294 * Construct custom config from the kernel's configuration 295 */ 296#define DEFAULT_PARPORT 0 297#define DEFAULT_PROFILE PANEL_PROFILE_LARGE 298#define DEFAULT_KEYPAD_TYPE KEYPAD_TYPE_OLD 299#define DEFAULT_LCD_TYPE LCD_TYPE_OLD 300#define DEFAULT_LCD_HEIGHT 2 301#define DEFAULT_LCD_WIDTH 40 | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Front panel driver for Linux 4 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu> 5 * Copyright (C) 2016-2017 Glider bvba 6 * 7 * This code drives an LCD module (/dev/lcd), and a keypad (/dev/keypad) 8 * connected to a parallel printer port. --- 285 unchanged lines hidden (view full) --- 294 * Construct custom config from the kernel's configuration 295 */ 296#define DEFAULT_PARPORT 0 297#define DEFAULT_PROFILE PANEL_PROFILE_LARGE 298#define DEFAULT_KEYPAD_TYPE KEYPAD_TYPE_OLD 299#define DEFAULT_LCD_TYPE LCD_TYPE_OLD 300#define DEFAULT_LCD_HEIGHT 2 301#define DEFAULT_LCD_WIDTH 40 |
302#define DEFAULT_LCD_BWIDTH 40 303#define DEFAULT_LCD_HWIDTH 64 | |
304#define DEFAULT_LCD_CHARSET LCD_CHARSET_NORMAL 305#define DEFAULT_LCD_PROTO LCD_PROTO_PARALLEL 306 307#define DEFAULT_LCD_PIN_E PIN_AUTOLF 308#define DEFAULT_LCD_PIN_RS PIN_SELECP 309#define DEFAULT_LCD_PIN_RW PIN_INITP 310#define DEFAULT_LCD_PIN_SCL PIN_STROBE 311#define DEFAULT_LCD_PIN_SDA PIN_D0 --- 496 unchanged lines hidden (view full) --- 808 w_dtr(pprt, data); 809 udelay(60); 810 spin_unlock_irq(&pprt_lock); 811} 812 813/* fills the display with spaces and resets X/Y */ 814static void lcd_clear_fast_s(struct charlcd *charlcd) 815{ | 302#define DEFAULT_LCD_CHARSET LCD_CHARSET_NORMAL 303#define DEFAULT_LCD_PROTO LCD_PROTO_PARALLEL 304 305#define DEFAULT_LCD_PIN_E PIN_AUTOLF 306#define DEFAULT_LCD_PIN_RS PIN_SELECP 307#define DEFAULT_LCD_PIN_RW PIN_INITP 308#define DEFAULT_LCD_PIN_SCL PIN_STROBE 309#define DEFAULT_LCD_PIN_SDA PIN_D0 --- 496 unchanged lines hidden (view full) --- 806 w_dtr(pprt, data); 807 udelay(60); 808 spin_unlock_irq(&pprt_lock); 809} 810 811/* fills the display with spaces and resets X/Y */ 812static void lcd_clear_fast_s(struct charlcd *charlcd) 813{ |
814 struct hd44780_common *hdc = charlcd->drvdata; |
|
816 int pos; 817 818 spin_lock_irq(&pprt_lock); | 815 int pos; 816 817 spin_lock_irq(&pprt_lock); |
819 for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { | 818 for (pos = 0; pos < charlcd->height * hdc->hwidth; pos++) { |
820 lcd_send_serial(0x5F); /* R/W=W, RS=1 */ 821 lcd_send_serial(' ' & 0x0F); 822 lcd_send_serial((' ' >> 4) & 0x0F); 823 /* the shortest data takes at least 40 us */ 824 udelay(40); 825 } 826 spin_unlock_irq(&pprt_lock); 827} 828 829/* fills the display with spaces and resets X/Y */ 830static void lcd_clear_fast_p8(struct charlcd *charlcd) 831{ | 819 lcd_send_serial(0x5F); /* R/W=W, RS=1 */ 820 lcd_send_serial(' ' & 0x0F); 821 lcd_send_serial((' ' >> 4) & 0x0F); 822 /* the shortest data takes at least 40 us */ 823 udelay(40); 824 } 825 spin_unlock_irq(&pprt_lock); 826} 827 828/* fills the display with spaces and resets X/Y */ 829static void lcd_clear_fast_p8(struct charlcd *charlcd) 830{ |
831 struct hd44780_common *hdc = charlcd->drvdata; |
|
832 int pos; 833 834 spin_lock_irq(&pprt_lock); | 832 int pos; 833 834 spin_lock_irq(&pprt_lock); |
835 for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { | 835 for (pos = 0; pos < charlcd->height * hdc->hwidth; pos++) { |
836 /* present the data to the data port */ 837 w_dtr(pprt, ' '); 838 839 /* maintain the data during 20 us before the strobe */ 840 udelay(20); 841 842 set_bit(LCD_BIT_E, bits); 843 set_bit(LCD_BIT_RS, bits); --- 10 unchanged lines hidden (view full) --- 854 udelay(45); 855 } 856 spin_unlock_irq(&pprt_lock); 857} 858 859/* fills the display with spaces and resets X/Y */ 860static void lcd_clear_fast_tilcd(struct charlcd *charlcd) 861{ | 836 /* present the data to the data port */ 837 w_dtr(pprt, ' '); 838 839 /* maintain the data during 20 us before the strobe */ 840 udelay(20); 841 842 set_bit(LCD_BIT_E, bits); 843 set_bit(LCD_BIT_RS, bits); --- 10 unchanged lines hidden (view full) --- 854 udelay(45); 855 } 856 spin_unlock_irq(&pprt_lock); 857} 858 859/* fills the display with spaces and resets X/Y */ 860static void lcd_clear_fast_tilcd(struct charlcd *charlcd) 861{ |
862 struct hd44780_common *hdc = charlcd->drvdata; |
|
862 int pos; 863 864 spin_lock_irq(&pprt_lock); | 863 int pos; 864 865 spin_lock_irq(&pprt_lock); |
865 for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { | 866 for (pos = 0; pos < charlcd->height * hdc->hwidth; pos++) { |
866 /* present the data to the data port */ 867 w_dtr(pprt, ' '); 868 udelay(60); 869 } 870 871 spin_unlock_irq(&pprt_lock); 872} 873 --- 23 unchanged lines hidden (view full) --- 897{ 898 struct charlcd *charlcd; 899 struct hd44780_common *hdc; 900 901 hdc = hd44780_common_alloc(); 902 if (!hdc) 903 return; 904 | 867 /* present the data to the data port */ 868 w_dtr(pprt, ' '); 869 udelay(60); 870 } 871 872 spin_unlock_irq(&pprt_lock); 873} 874 --- 23 unchanged lines hidden (view full) --- 898{ 899 struct charlcd *charlcd; 900 struct hd44780_common *hdc; 901 902 hdc = hd44780_common_alloc(); 903 if (!hdc) 904 return; 905 |
905 charlcd = charlcd_alloc(0); | 906 charlcd = charlcd_alloc(); |
906 if (!charlcd) { 907 kfree(hdc); 908 return; 909 } 910 911 hdc->hd44780 = &lcd; 912 charlcd->drvdata = hdc; 913 914 /* 915 * Init lcd struct with load-time values to preserve exact 916 * current functionality (at least for now). 917 */ 918 charlcd->height = lcd_height; 919 charlcd->width = lcd_width; | 907 if (!charlcd) { 908 kfree(hdc); 909 return; 910 } 911 912 hdc->hd44780 = &lcd; 913 charlcd->drvdata = hdc; 914 915 /* 916 * Init lcd struct with load-time values to preserve exact 917 * current functionality (at least for now). 918 */ 919 charlcd->height = lcd_height; 920 charlcd->width = lcd_width; |
920 charlcd->bwidth = lcd_bwidth; 921 charlcd->hwidth = lcd_hwidth; | 921 hdc->bwidth = lcd_bwidth; 922 hdc->hwidth = lcd_hwidth; |
922 923 switch (selected_lcd_type) { 924 case LCD_TYPE_OLD: 925 /* parallel mode, 8 bits */ 926 lcd.proto = LCD_PROTO_PARALLEL; 927 lcd.charset = LCD_CHARSET_NORMAL; 928 lcd.pins.e = PIN_STROBE; 929 lcd.pins.rs = PIN_AUTOLF; 930 931 charlcd->width = 40; | 923 924 switch (selected_lcd_type) { 925 case LCD_TYPE_OLD: 926 /* parallel mode, 8 bits */ 927 lcd.proto = LCD_PROTO_PARALLEL; 928 lcd.charset = LCD_CHARSET_NORMAL; 929 lcd.pins.e = PIN_STROBE; 930 lcd.pins.rs = PIN_AUTOLF; 931 932 charlcd->width = 40; |
932 charlcd->bwidth = 40; 933 charlcd->hwidth = 64; | 933 hdc->bwidth = 40; 934 hdc->hwidth = 64; |
934 charlcd->height = 2; 935 break; 936 case LCD_TYPE_KS0074: 937 /* serial mode, ks0074 */ 938 lcd.proto = LCD_PROTO_SERIAL; 939 lcd.charset = LCD_CHARSET_KS0074; 940 lcd.pins.bl = PIN_AUTOLF; 941 lcd.pins.cl = PIN_STROBE; 942 lcd.pins.da = PIN_D0; 943 944 charlcd->width = 16; | 935 charlcd->height = 2; 936 break; 937 case LCD_TYPE_KS0074: 938 /* serial mode, ks0074 */ 939 lcd.proto = LCD_PROTO_SERIAL; 940 lcd.charset = LCD_CHARSET_KS0074; 941 lcd.pins.bl = PIN_AUTOLF; 942 lcd.pins.cl = PIN_STROBE; 943 lcd.pins.da = PIN_D0; 944 945 charlcd->width = 16; |
945 charlcd->bwidth = 40; 946 charlcd->hwidth = 16; | 946 hdc->bwidth = 40; 947 hdc->hwidth = 16; |
947 charlcd->height = 2; 948 break; 949 case LCD_TYPE_NEXCOM: 950 /* parallel mode, 8 bits, generic */ 951 lcd.proto = LCD_PROTO_PARALLEL; 952 lcd.charset = LCD_CHARSET_NORMAL; 953 lcd.pins.e = PIN_AUTOLF; 954 lcd.pins.rs = PIN_SELECP; 955 lcd.pins.rw = PIN_INITP; 956 957 charlcd->width = 16; | 948 charlcd->height = 2; 949 break; 950 case LCD_TYPE_NEXCOM: 951 /* parallel mode, 8 bits, generic */ 952 lcd.proto = LCD_PROTO_PARALLEL; 953 lcd.charset = LCD_CHARSET_NORMAL; 954 lcd.pins.e = PIN_AUTOLF; 955 lcd.pins.rs = PIN_SELECP; 956 lcd.pins.rw = PIN_INITP; 957 958 charlcd->width = 16; |
958 charlcd->bwidth = 40; 959 charlcd->hwidth = 64; | 959 hdc->bwidth = 40; 960 hdc->hwidth = 64; |
960 charlcd->height = 2; 961 break; 962 case LCD_TYPE_CUSTOM: 963 /* customer-defined */ 964 lcd.proto = DEFAULT_LCD_PROTO; 965 lcd.charset = DEFAULT_LCD_CHARSET; 966 /* default geometry will be set later */ 967 break; 968 case LCD_TYPE_HANTRONIX: 969 /* parallel mode, 8 bits, hantronix-like */ 970 default: 971 lcd.proto = LCD_PROTO_PARALLEL; 972 lcd.charset = LCD_CHARSET_NORMAL; 973 lcd.pins.e = PIN_STROBE; 974 lcd.pins.rs = PIN_SELECP; 975 976 charlcd->width = 16; | 961 charlcd->height = 2; 962 break; 963 case LCD_TYPE_CUSTOM: 964 /* customer-defined */ 965 lcd.proto = DEFAULT_LCD_PROTO; 966 lcd.charset = DEFAULT_LCD_CHARSET; 967 /* default geometry will be set later */ 968 break; 969 case LCD_TYPE_HANTRONIX: 970 /* parallel mode, 8 bits, hantronix-like */ 971 default: 972 lcd.proto = LCD_PROTO_PARALLEL; 973 lcd.charset = LCD_CHARSET_NORMAL; 974 lcd.pins.e = PIN_STROBE; 975 lcd.pins.rs = PIN_SELECP; 976 977 charlcd->width = 16; |
977 charlcd->bwidth = 40; 978 charlcd->hwidth = 64; | 978 hdc->bwidth = 40; 979 hdc->hwidth = 64; |
979 charlcd->height = 2; 980 break; 981 } 982 983 /* Overwrite with module params set on loading */ 984 if (lcd_height != NOT_SET) 985 charlcd->height = lcd_height; 986 if (lcd_width != NOT_SET) 987 charlcd->width = lcd_width; 988 if (lcd_bwidth != NOT_SET) | 980 charlcd->height = 2; 981 break; 982 } 983 984 /* Overwrite with module params set on loading */ 985 if (lcd_height != NOT_SET) 986 charlcd->height = lcd_height; 987 if (lcd_width != NOT_SET) 988 charlcd->width = lcd_width; 989 if (lcd_bwidth != NOT_SET) |
989 charlcd->bwidth = lcd_bwidth; | 990 hdc->bwidth = lcd_bwidth; |
990 if (lcd_hwidth != NOT_SET) | 991 if (lcd_hwidth != NOT_SET) |
991 charlcd->hwidth = lcd_hwidth; | 992 hdc->hwidth = lcd_hwidth; |
992 if (lcd_charset != NOT_SET) 993 lcd.charset = lcd_charset; 994 if (lcd_proto != NOT_SET) 995 lcd.proto = lcd_proto; 996 if (lcd_e_pin != PIN_NOT_SET) 997 lcd.pins.e = lcd_e_pin; 998 if (lcd_rs_pin != PIN_NOT_SET) 999 lcd.pins.rs = lcd_rs_pin; --- 4 unchanged lines hidden (view full) --- 1004 if (lcd_da_pin != PIN_NOT_SET) 1005 lcd.pins.da = lcd_da_pin; 1006 if (lcd_bl_pin != PIN_NOT_SET) 1007 lcd.pins.bl = lcd_bl_pin; 1008 1009 /* this is used to catch wrong and default values */ 1010 if (charlcd->width <= 0) 1011 charlcd->width = DEFAULT_LCD_WIDTH; | 993 if (lcd_charset != NOT_SET) 994 lcd.charset = lcd_charset; 995 if (lcd_proto != NOT_SET) 996 lcd.proto = lcd_proto; 997 if (lcd_e_pin != PIN_NOT_SET) 998 lcd.pins.e = lcd_e_pin; 999 if (lcd_rs_pin != PIN_NOT_SET) 1000 lcd.pins.rs = lcd_rs_pin; --- 4 unchanged lines hidden (view full) --- 1005 if (lcd_da_pin != PIN_NOT_SET) 1006 lcd.pins.da = lcd_da_pin; 1007 if (lcd_bl_pin != PIN_NOT_SET) 1008 lcd.pins.bl = lcd_bl_pin; 1009 1010 /* this is used to catch wrong and default values */ 1011 if (charlcd->width <= 0) 1012 charlcd->width = DEFAULT_LCD_WIDTH; |
1012 if (charlcd->bwidth <= 0) 1013 charlcd->bwidth = DEFAULT_LCD_BWIDTH; 1014 if (charlcd->hwidth <= 0) 1015 charlcd->hwidth = DEFAULT_LCD_HWIDTH; | 1013 if (hdc->bwidth <= 0) 1014 hdc->bwidth = DEFAULT_LCD_BWIDTH; 1015 if (hdc->hwidth <= 0) 1016 hdc->hwidth = DEFAULT_LCD_HWIDTH; |
1016 if (charlcd->height <= 0) 1017 charlcd->height = DEFAULT_LCD_HEIGHT; 1018 1019 if (lcd.proto == LCD_PROTO_SERIAL) { /* SERIAL */ 1020 charlcd->ops = &charlcd_serial_ops; 1021 1022 if (lcd.pins.cl == PIN_NOT_SET) 1023 lcd.pins.cl = DEFAULT_LCD_PIN_SCL; --- 784 unchanged lines hidden --- | 1017 if (charlcd->height <= 0) 1018 charlcd->height = DEFAULT_LCD_HEIGHT; 1019 1020 if (lcd.proto == LCD_PROTO_SERIAL) { /* SERIAL */ 1021 charlcd->ops = &charlcd_serial_ops; 1022 1023 if (lcd.pins.cl == PIN_NOT_SET) 1024 lcd.pins.cl = DEFAULT_LCD_PIN_SCL; --- 784 unchanged lines hidden --- |