Home | History | Annotate | Line # | Download | only in display
      1  1.1  riastrad /*	$NetBSD: dvo_ns2501.c,v 1.2 2021/12/18 23:45:29 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  *
      5  1.1  riastrad  * Copyright (c) 2012 Gilles Dartiguelongue, Thomas Richter
      6  1.1  riastrad  *
      7  1.1  riastrad  * All Rights Reserved.
      8  1.1  riastrad  *
      9  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
     10  1.1  riastrad  * copy of this software and associated documentation files (the
     11  1.1  riastrad  * "Software"), to deal in the Software without restriction, including
     12  1.1  riastrad  * without limitation the rights to use, copy, modify, merge, publish,
     13  1.1  riastrad  * distribute, sub license, and/or sell copies of the Software, and to
     14  1.1  riastrad  * permit persons to whom the Software is furnished to do so, subject to
     15  1.1  riastrad  * the following conditions:
     16  1.1  riastrad  *
     17  1.1  riastrad  * The above copyright notice and this permission notice (including the
     18  1.1  riastrad  * next paragraph) shall be included in all copies or substantial portions
     19  1.1  riastrad  * of the Software.
     20  1.1  riastrad  *
     21  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     22  1.1  riastrad  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     23  1.1  riastrad  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
     24  1.1  riastrad  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     25  1.1  riastrad  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     26  1.1  riastrad  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     27  1.1  riastrad  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     28  1.1  riastrad  *
     29  1.1  riastrad  */
     30  1.1  riastrad 
     31  1.1  riastrad #include <sys/cdefs.h>
     32  1.1  riastrad __KERNEL_RCSID(0, "$NetBSD: dvo_ns2501.c,v 1.2 2021/12/18 23:45:29 riastradh Exp $");
     33  1.1  riastrad 
     34  1.1  riastrad #include "i915_drv.h"
     35  1.1  riastrad #include "i915_reg.h"
     36  1.1  riastrad #include "intel_display_types.h"
     37  1.1  riastrad #include "intel_dvo_dev.h"
     38  1.1  riastrad 
     39  1.1  riastrad #define NS2501_VID 0x1305
     40  1.1  riastrad #define NS2501_DID 0x6726
     41  1.1  riastrad 
     42  1.1  riastrad #define NS2501_VID_LO 0x00
     43  1.1  riastrad #define NS2501_VID_HI 0x01
     44  1.1  riastrad #define NS2501_DID_LO 0x02
     45  1.1  riastrad #define NS2501_DID_HI 0x03
     46  1.1  riastrad #define NS2501_REV 0x04
     47  1.1  riastrad #define NS2501_RSVD 0x05
     48  1.1  riastrad #define NS2501_FREQ_LO 0x06
     49  1.1  riastrad #define NS2501_FREQ_HI 0x07
     50  1.1  riastrad 
     51  1.1  riastrad #define NS2501_REG8 0x08
     52  1.1  riastrad #define NS2501_8_VEN (1<<5)
     53  1.1  riastrad #define NS2501_8_HEN (1<<4)
     54  1.1  riastrad #define NS2501_8_DSEL (1<<3)
     55  1.1  riastrad #define NS2501_8_BPAS (1<<2)
     56  1.1  riastrad #define NS2501_8_RSVD (1<<1)
     57  1.1  riastrad #define NS2501_8_PD (1<<0)
     58  1.1  riastrad 
     59  1.1  riastrad #define NS2501_REG9 0x09
     60  1.1  riastrad #define NS2501_9_VLOW (1<<7)
     61  1.1  riastrad #define NS2501_9_MSEL_MASK (0x7<<4)
     62  1.1  riastrad #define NS2501_9_TSEL (1<<3)
     63  1.1  riastrad #define NS2501_9_RSEN (1<<2)
     64  1.1  riastrad #define NS2501_9_RSVD (1<<1)
     65  1.1  riastrad #define NS2501_9_MDI (1<<0)
     66  1.1  riastrad 
     67  1.1  riastrad #define NS2501_REGC 0x0c
     68  1.1  riastrad 
     69  1.1  riastrad /*
     70  1.1  riastrad  * The following registers are not part of the official datasheet
     71  1.1  riastrad  * and are the result of reverse engineering.
     72  1.1  riastrad  */
     73  1.1  riastrad 
     74  1.1  riastrad /*
     75  1.1  riastrad  * Register c0 controls how the DVO synchronizes with
     76  1.1  riastrad  * its input.
     77  1.1  riastrad  */
     78  1.1  riastrad #define NS2501_REGC0 0xc0
     79  1.1  riastrad #define NS2501_C0_ENABLE (1<<0)	/* enable the DVO sync in general */
     80  1.1  riastrad #define NS2501_C0_HSYNC (1<<1)	/* synchronize horizontal with input */
     81  1.1  riastrad #define NS2501_C0_VSYNC (1<<2)	/* synchronize vertical with input */
     82  1.1  riastrad #define NS2501_C0_RESET (1<<7)	/* reset the synchronization flip/flops */
     83  1.1  riastrad 
     84  1.1  riastrad /*
     85  1.1  riastrad  * Register 41 is somehow related to the sync register and sync
     86  1.1  riastrad  * configuration. It should be 0x32 whenever regC0 is 0x05 (hsync off)
     87  1.1  riastrad  * and 0x00 otherwise.
     88  1.1  riastrad  */
     89  1.1  riastrad #define NS2501_REG41 0x41
     90  1.1  riastrad 
     91  1.1  riastrad /*
     92  1.1  riastrad  * this register controls the dithering of the DVO
     93  1.1  riastrad  * One bit enables it, the other define the dithering depth.
     94  1.1  riastrad  * The higher the value, the lower the dithering depth.
     95  1.1  riastrad  */
     96  1.1  riastrad #define NS2501_F9_REG 0xf9
     97  1.1  riastrad #define NS2501_F9_ENABLE (1<<0)		/* if set, dithering is enabled */
     98  1.1  riastrad #define NS2501_F9_DITHER_MASK (0x7f<<1)	/* controls the dither depth */
     99  1.1  riastrad #define NS2501_F9_DITHER_SHIFT 1	/* shifts the dither mask */
    100  1.1  riastrad 
    101  1.1  riastrad /*
    102  1.1  riastrad  * PLL configuration register. This is a pair of registers,
    103  1.1  riastrad  * one single byte register at 1B, and a pair at 1C,1D.
    104  1.1  riastrad  * These registers are counters/dividers.
    105  1.1  riastrad  */
    106  1.1  riastrad #define NS2501_REG1B 0x1b /* one byte PLL control register */
    107  1.1  riastrad #define NS2501_REG1C 0x1c /* low-part of the second register */
    108  1.1  riastrad #define NS2501_REG1D 0x1d /* high-part of the second register */
    109  1.1  riastrad 
    110  1.1  riastrad /*
    111  1.1  riastrad  * Scaler control registers. Horizontal at b8,b9,
    112  1.1  riastrad  * vertical at 10,11. The scale factor is computed as
    113  1.1  riastrad  * 2^16/control-value. The low-byte comes first.
    114  1.1  riastrad  */
    115  1.1  riastrad #define NS2501_REG10 0x10 /* low-byte vertical scaler */
    116  1.1  riastrad #define NS2501_REG11 0x11 /* high-byte vertical scaler */
    117  1.1  riastrad #define NS2501_REGB8 0xb8 /* low-byte horizontal scaler */
    118  1.1  riastrad #define NS2501_REGB9 0xb9 /* high-byte horizontal scaler */
    119  1.1  riastrad 
    120  1.1  riastrad /*
    121  1.1  riastrad  * Display window definition. This consists of four registers
    122  1.1  riastrad  * per dimension. One register pair defines the start of the
    123  1.1  riastrad  * display, one the end.
    124  1.1  riastrad  * As far as I understand, this defines the window within which
    125  1.1  riastrad  * the scaler samples the input.
    126  1.1  riastrad  */
    127  1.1  riastrad #define NS2501_REGC1 0xc1 /* low-byte horizontal display start */
    128  1.1  riastrad #define NS2501_REGC2 0xc2 /* high-byte horizontal display start */
    129  1.1  riastrad #define NS2501_REGC3 0xc3 /* low-byte horizontal display stop */
    130  1.1  riastrad #define NS2501_REGC4 0xc4 /* high-byte horizontal display stop */
    131  1.1  riastrad #define NS2501_REGC5 0xc5 /* low-byte vertical display start */
    132  1.1  riastrad #define NS2501_REGC6 0xc6 /* high-byte vertical display start */
    133  1.1  riastrad #define NS2501_REGC7 0xc7 /* low-byte vertical display stop */
    134  1.1  riastrad #define NS2501_REGC8 0xc8 /* high-byte vertical display stop */
    135  1.1  riastrad 
    136  1.1  riastrad /*
    137  1.1  riastrad  * The following register pair seems to define the start of
    138  1.1  riastrad  * the vertical sync. If automatic syncing is enabled, and the
    139  1.1  riastrad  * register value defines a sync pulse that is later than the
    140  1.1  riastrad  * incoming sync, then the register value is ignored and the
    141  1.1  riastrad  * external hsync triggers the synchronization.
    142  1.1  riastrad  */
    143  1.1  riastrad #define NS2501_REG80 0x80 /* low-byte vsync-start */
    144  1.1  riastrad #define NS2501_REG81 0x81 /* high-byte vsync-start */
    145  1.1  riastrad 
    146  1.1  riastrad /*
    147  1.1  riastrad  * The following register pair seems to define the total number
    148  1.1  riastrad  * of lines created at the output side of the scaler.
    149  1.1  riastrad  * This is again a low-high register pair.
    150  1.1  riastrad  */
    151  1.1  riastrad #define NS2501_REG82 0x82 /* output display height, low byte */
    152  1.1  riastrad #define NS2501_REG83 0x83 /* output display height, high byte */
    153  1.1  riastrad 
    154  1.1  riastrad /*
    155  1.1  riastrad  * The following registers define the end of the front-porch
    156  1.1  riastrad  * in horizontal and vertical position and hence allow to shift
    157  1.1  riastrad  * the image left/right or up/down.
    158  1.1  riastrad  */
    159  1.1  riastrad #define NS2501_REG98 0x98 /* horizontal start of display + 256, low */
    160  1.1  riastrad #define NS2501_REG99 0x99 /* horizontal start of display + 256, high */
    161  1.1  riastrad #define NS2501_REG8E 0x8e /* vertical start of the display, low byte */
    162  1.1  riastrad #define NS2501_REG8F 0x8f /* vertical start of the display, high byte */
    163  1.1  riastrad 
    164  1.1  riastrad /*
    165  1.1  riastrad  * The following register pair control the function of the
    166  1.1  riastrad  * backlight and the DVO output. To enable the corresponding
    167  1.1  riastrad  * function, the corresponding bit must be set in both registers.
    168  1.1  riastrad  */
    169  1.1  riastrad #define NS2501_REG34 0x34 /* DVO enable functions, first register */
    170  1.1  riastrad #define NS2501_REG35 0x35 /* DVO enable functions, second register */
    171  1.1  riastrad #define NS2501_34_ENABLE_OUTPUT (1<<0) /* enable DVO output */
    172  1.1  riastrad #define NS2501_34_ENABLE_BACKLIGHT (1<<1) /* enable backlight */
    173  1.1  riastrad 
    174  1.1  riastrad /*
    175  1.1  riastrad  * Registers 9C and 9D define the vertical output offset
    176  1.1  riastrad  * of the visible region.
    177  1.1  riastrad  */
    178  1.1  riastrad #define NS2501_REG9C 0x9c
    179  1.1  riastrad #define NS2501_REG9D 0x9d
    180  1.1  riastrad 
    181  1.1  riastrad /*
    182  1.1  riastrad  * The register 9F defines the dithering. This requires the
    183  1.1  riastrad  * scaler to be ON. Bit 0 enables dithering, the remaining
    184  1.1  riastrad  * bits control the depth of the dither. The higher the value,
    185  1.1  riastrad  * the LOWER the dithering amplitude. A good value seems to be
    186  1.1  riastrad  * 15 (total register value).
    187  1.1  riastrad  */
    188  1.1  riastrad #define NS2501_REGF9 0xf9
    189  1.1  riastrad #define NS2501_F9_ENABLE_DITHER (1<<0) /* enable dithering */
    190  1.1  riastrad #define NS2501_F9_DITHER_MASK (0x7f<<1) /* dither masking */
    191  1.1  riastrad #define NS2501_F9_DITHER_SHIFT 1	/* upshift of the dither mask */
    192  1.1  riastrad 
    193  1.1  riastrad enum {
    194  1.1  riastrad 	MODE_640x480,
    195  1.1  riastrad 	MODE_800x600,
    196  1.1  riastrad 	MODE_1024x768,
    197  1.1  riastrad };
    198  1.1  riastrad 
    199  1.1  riastrad struct ns2501_reg {
    200  1.1  riastrad 	u8 offset;
    201  1.1  riastrad 	u8 value;
    202  1.1  riastrad };
    203  1.1  riastrad 
    204  1.1  riastrad /*
    205  1.1  riastrad  * The following structure keeps the complete configuration of
    206  1.1  riastrad  * the DVO, given a specific output configuration.
    207  1.1  riastrad  * This is pretty much guess-work from reverse-engineering, so
    208  1.1  riastrad  * read all this with a grain of salt.
    209  1.1  riastrad  */
    210  1.1  riastrad struct ns2501_configuration {
    211  1.1  riastrad 	u8 sync;		/* configuration of the C0 register */
    212  1.1  riastrad 	u8 conf;		/* configuration register 8 */
    213  1.1  riastrad 	u8 syncb;		/* configuration register 41 */
    214  1.1  riastrad 	u8 dither;		/* configuration of the dithering */
    215  1.1  riastrad 	u8 pll_a;		/* PLL configuration, register A, 1B */
    216  1.1  riastrad 	u16 pll_b;		/* PLL configuration, register B, 1C/1D */
    217  1.1  riastrad 	u16 hstart;		/* horizontal start, registers C1/C2 */
    218  1.1  riastrad 	u16 hstop;		/* horizontal total, registers C3/C4 */
    219  1.1  riastrad 	u16 vstart;		/* vertical start, registers C5/C6 */
    220  1.1  riastrad 	u16 vstop;		/* vertical total, registers C7/C8 */
    221  1.1  riastrad 	u16 vsync;		/* manual vertical sync start, 80/81 */
    222  1.1  riastrad 	u16 vtotal;		/* number of lines generated, 82/83 */
    223  1.1  riastrad 	u16 hpos;		/* horizontal position + 256, 98/99  */
    224  1.1  riastrad 	u16 vpos;		/* vertical position, 8e/8f */
    225  1.1  riastrad 	u16 voffs;		/* vertical output offset, 9c/9d */
    226  1.1  riastrad 	u16 hscale;		/* horizontal scaling factor, b8/b9 */
    227  1.1  riastrad 	u16 vscale;		/* vertical scaling factor, 10/11 */
    228  1.1  riastrad };
    229  1.1  riastrad 
    230  1.1  riastrad /*
    231  1.1  riastrad  * DVO configuration values, partially based on what the BIOS
    232  1.1  riastrad  * of the Fujitsu Lifebook S6010 writes into registers,
    233  1.1  riastrad  * partially found by manual tweaking. These configurations assume
    234  1.1  riastrad  * a 1024x768 panel.
    235  1.1  riastrad  */
    236  1.1  riastrad static const struct ns2501_configuration ns2501_modes[] = {
    237  1.1  riastrad 	[MODE_640x480] = {
    238  1.1  riastrad 		.sync	= NS2501_C0_ENABLE | NS2501_C0_VSYNC,
    239  1.1  riastrad 		.conf	= NS2501_8_VEN | NS2501_8_HEN | NS2501_8_PD,
    240  1.1  riastrad 		.syncb	= 0x32,
    241  1.1  riastrad 		.dither	= 0x0f,
    242  1.1  riastrad 		.pll_a	= 17,
    243  1.1  riastrad 		.pll_b	= 852,
    244  1.1  riastrad 		.hstart	= 144,
    245  1.1  riastrad 		.hstop	= 783,
    246  1.1  riastrad 		.vstart	= 22,
    247  1.1  riastrad 		.vstop	= 514,
    248  1.1  riastrad 		.vsync	= 2047, /* actually, ignored with this config */
    249  1.1  riastrad 		.vtotal	= 1341,
    250  1.1  riastrad 		.hpos	= 0,
    251  1.1  riastrad 		.vpos	= 16,
    252  1.1  riastrad 		.voffs	= 36,
    253  1.1  riastrad 		.hscale	= 40960,
    254  1.1  riastrad 		.vscale	= 40960
    255  1.1  riastrad 	},
    256  1.1  riastrad 	[MODE_800x600] = {
    257  1.1  riastrad 		.sync	= NS2501_C0_ENABLE |
    258  1.1  riastrad 			  NS2501_C0_HSYNC | NS2501_C0_VSYNC,
    259  1.1  riastrad 		.conf   = NS2501_8_VEN | NS2501_8_HEN | NS2501_8_PD,
    260  1.1  riastrad 		.syncb	= 0x00,
    261  1.1  riastrad 		.dither	= 0x0f,
    262  1.1  riastrad 		.pll_a	= 25,
    263  1.1  riastrad 		.pll_b	= 612,
    264  1.1  riastrad 		.hstart	= 215,
    265  1.1  riastrad 		.hstop	= 1016,
    266  1.1  riastrad 		.vstart	= 26,
    267  1.1  riastrad 		.vstop	= 627,
    268  1.1  riastrad 		.vsync	= 807,
    269  1.1  riastrad 		.vtotal	= 1341,
    270  1.1  riastrad 		.hpos	= 0,
    271  1.1  riastrad 		.vpos	= 4,
    272  1.1  riastrad 		.voffs	= 35,
    273  1.1  riastrad 		.hscale	= 51248,
    274  1.1  riastrad 		.vscale	= 51232
    275  1.1  riastrad 	},
    276  1.1  riastrad 	[MODE_1024x768] = {
    277  1.1  riastrad 		.sync	= NS2501_C0_ENABLE | NS2501_C0_VSYNC,
    278  1.1  riastrad 		.conf   = NS2501_8_VEN | NS2501_8_HEN | NS2501_8_PD,
    279  1.1  riastrad 		.syncb	= 0x32,
    280  1.1  riastrad 		.dither	= 0x0f,
    281  1.1  riastrad 		.pll_a	= 11,
    282  1.1  riastrad 		.pll_b	= 1350,
    283  1.1  riastrad 		.hstart	= 276,
    284  1.1  riastrad 		.hstop	= 1299,
    285  1.1  riastrad 		.vstart	= 15,
    286  1.1  riastrad 		.vstop	= 1056,
    287  1.1  riastrad 		.vsync	= 2047,
    288  1.1  riastrad 		.vtotal	= 1341,
    289  1.1  riastrad 		.hpos	= 0,
    290  1.1  riastrad 		.vpos	= 7,
    291  1.1  riastrad 		.voffs	= 27,
    292  1.1  riastrad 		.hscale	= 65535,
    293  1.1  riastrad 		.vscale	= 65535
    294  1.1  riastrad 	}
    295  1.1  riastrad };
    296  1.1  riastrad 
    297  1.1  riastrad /*
    298  1.1  riastrad  * Other configuration values left by the BIOS of the
    299  1.1  riastrad  * Fujitsu S6010 in the DVO control registers. Their
    300  1.1  riastrad  * value does not depend on the BIOS and their meaning
    301  1.1  riastrad  * is unknown.
    302  1.1  riastrad  */
    303  1.1  riastrad 
    304  1.1  riastrad static const struct ns2501_reg mode_agnostic_values[] = {
    305  1.1  riastrad 	/* 08 is mode specific */
    306  1.1  riastrad 	[0] = { .offset = 0x0a, .value = 0x81, },
    307  1.1  riastrad 	/* 10,11 are part of the mode specific configuration */
    308  1.1  riastrad 	[1] = { .offset = 0x12, .value = 0x02, },
    309  1.1  riastrad 	[2] = { .offset = 0x18, .value = 0x07, },
    310  1.1  riastrad 	[3] = { .offset = 0x19, .value = 0x00, },
    311  1.1  riastrad 	[4] = { .offset = 0x1a, .value = 0x00, }, /* PLL?, ignored */
    312  1.1  riastrad 	/* 1b,1c,1d are part of the mode specific configuration */
    313  1.1  riastrad 	[5] = { .offset = 0x1e, .value = 0x02, },
    314  1.1  riastrad 	[6] = { .offset = 0x1f, .value = 0x40, },
    315  1.1  riastrad 	[7] = { .offset = 0x20, .value = 0x00, },
    316  1.1  riastrad 	[8] = { .offset = 0x21, .value = 0x00, },
    317  1.1  riastrad 	[9] = { .offset = 0x22, .value = 0x00, },
    318  1.1  riastrad 	[10] = { .offset = 0x23, .value = 0x00, },
    319  1.1  riastrad 	[11] = { .offset = 0x24, .value = 0x00, },
    320  1.1  riastrad 	[12] = { .offset = 0x25, .value = 0x00, },
    321  1.1  riastrad 	[13] = { .offset = 0x26, .value = 0x00, },
    322  1.1  riastrad 	[14] = { .offset = 0x27, .value = 0x00, },
    323  1.1  riastrad 	[15] = { .offset = 0x7e, .value = 0x18, },
    324  1.1  riastrad 	/* 80-84 are part of the mode-specific configuration */
    325  1.1  riastrad 	[16] = { .offset = 0x84, .value = 0x00, },
    326  1.1  riastrad 	[17] = { .offset = 0x85, .value = 0x00, },
    327  1.1  riastrad 	[18] = { .offset = 0x86, .value = 0x00, },
    328  1.1  riastrad 	[19] = { .offset = 0x87, .value = 0x00, },
    329  1.1  riastrad 	[20] = { .offset = 0x88, .value = 0x00, },
    330  1.1  riastrad 	[21] = { .offset = 0x89, .value = 0x00, },
    331  1.1  riastrad 	[22] = { .offset = 0x8a, .value = 0x00, },
    332  1.1  riastrad 	[23] = { .offset = 0x8b, .value = 0x00, },
    333  1.1  riastrad 	[24] = { .offset = 0x8c, .value = 0x10, },
    334  1.1  riastrad 	[25] = { .offset = 0x8d, .value = 0x02, },
    335  1.1  riastrad 	/* 8e,8f are part of the mode-specific configuration */
    336  1.1  riastrad 	[26] = { .offset = 0x90, .value = 0xff, },
    337  1.1  riastrad 	[27] = { .offset = 0x91, .value = 0x07, },
    338  1.1  riastrad 	[28] = { .offset = 0x92, .value = 0xa0, },
    339  1.1  riastrad 	[29] = { .offset = 0x93, .value = 0x02, },
    340  1.1  riastrad 	[30] = { .offset = 0x94, .value = 0x00, },
    341  1.1  riastrad 	[31] = { .offset = 0x95, .value = 0x00, },
    342  1.1  riastrad 	[32] = { .offset = 0x96, .value = 0x05, },
    343  1.1  riastrad 	[33] = { .offset = 0x97, .value = 0x00, },
    344  1.1  riastrad 	/* 98,99 are part of the mode-specific configuration */
    345  1.1  riastrad 	[34] = { .offset = 0x9a, .value = 0x88, },
    346  1.1  riastrad 	[35] = { .offset = 0x9b, .value = 0x00, },
    347  1.1  riastrad 	/* 9c,9d are part of the mode-specific configuration */
    348  1.1  riastrad 	[36] = { .offset = 0x9e, .value = 0x25, },
    349  1.1  riastrad 	[37] = { .offset = 0x9f, .value = 0x03, },
    350  1.1  riastrad 	[38] = { .offset = 0xa0, .value = 0x28, },
    351  1.1  riastrad 	[39] = { .offset = 0xa1, .value = 0x01, },
    352  1.1  riastrad 	[40] = { .offset = 0xa2, .value = 0x28, },
    353  1.1  riastrad 	[41] = { .offset = 0xa3, .value = 0x05, },
    354  1.1  riastrad 	/* register 0xa4 is mode specific, but 0x80..0x84 works always */
    355  1.1  riastrad 	[42] = { .offset = 0xa4, .value = 0x84, },
    356  1.1  riastrad 	[43] = { .offset = 0xa5, .value = 0x00, },
    357  1.1  riastrad 	[44] = { .offset = 0xa6, .value = 0x00, },
    358  1.1  riastrad 	[45] = { .offset = 0xa7, .value = 0x00, },
    359  1.1  riastrad 	[46] = { .offset = 0xa8, .value = 0x00, },
    360  1.1  riastrad 	/* 0xa9 to 0xab are mode specific, but have no visible effect */
    361  1.1  riastrad 	[47] = { .offset = 0xa9, .value = 0x04, },
    362  1.1  riastrad 	[48] = { .offset = 0xaa, .value = 0x70, },
    363  1.1  riastrad 	[49] = { .offset = 0xab, .value = 0x4f, },
    364  1.1  riastrad 	[50] = { .offset = 0xac, .value = 0x00, },
    365  1.1  riastrad 	[51] = { .offset = 0xad, .value = 0x00, },
    366  1.1  riastrad 	[52] = { .offset = 0xb6, .value = 0x09, },
    367  1.1  riastrad 	[53] = { .offset = 0xb7, .value = 0x03, },
    368  1.1  riastrad 	/* b8,b9 are part of the mode-specific configuration */
    369  1.1  riastrad 	[54] = { .offset = 0xba, .value = 0x00, },
    370  1.1  riastrad 	[55] = { .offset = 0xbb, .value = 0x20, },
    371  1.1  riastrad 	[56] = { .offset = 0xf3, .value = 0x90, },
    372  1.1  riastrad 	[57] = { .offset = 0xf4, .value = 0x00, },
    373  1.1  riastrad 	[58] = { .offset = 0xf7, .value = 0x88, },
    374  1.1  riastrad 	/* f8 is mode specific, but the value does not matter */
    375  1.1  riastrad 	[59] = { .offset = 0xf8, .value = 0x0a, },
    376  1.1  riastrad 	[60] = { .offset = 0xf9, .value = 0x00, }
    377  1.1  riastrad };
    378  1.1  riastrad 
    379  1.1  riastrad static const struct ns2501_reg regs_init[] = {
    380  1.1  riastrad 	[0] = { .offset = 0x35, .value = 0xff, },
    381  1.1  riastrad 	[1] = { .offset = 0x34, .value = 0x00, },
    382  1.1  riastrad 	[2] = { .offset = 0x08, .value = 0x30, },
    383  1.1  riastrad };
    384  1.1  riastrad 
    385  1.1  riastrad struct ns2501_priv {
    386  1.1  riastrad 	bool quiet;
    387  1.1  riastrad 	const struct ns2501_configuration *conf;
    388  1.1  riastrad };
    389  1.1  riastrad 
    390  1.1  riastrad #define NSPTR(d) ((NS2501Ptr)(d->DriverPrivate.ptr))
    391  1.1  riastrad 
    392  1.1  riastrad /*
    393  1.1  riastrad ** Read a register from the ns2501.
    394  1.1  riastrad ** Returns true if successful, false otherwise.
    395  1.1  riastrad ** If it returns false, it might be wise to enable the
    396  1.1  riastrad ** DVO with the above function.
    397  1.1  riastrad */
    398  1.1  riastrad static bool ns2501_readb(struct intel_dvo_device *dvo, int addr, u8 *ch)
    399  1.1  riastrad {
    400  1.1  riastrad 	struct ns2501_priv *ns = dvo->dev_priv;
    401  1.1  riastrad 	struct i2c_adapter *adapter = dvo->i2c_bus;
    402  1.1  riastrad 	u8 out_buf[2];
    403  1.1  riastrad 	u8 in_buf[2];
    404  1.1  riastrad 
    405  1.1  riastrad 	struct i2c_msg msgs[] = {
    406  1.1  riastrad 		{
    407  1.1  riastrad 		 .addr = dvo->slave_addr,
    408  1.1  riastrad 		 .flags = 0,
    409  1.1  riastrad 		 .len = 1,
    410  1.1  riastrad 		 .buf = out_buf,
    411  1.1  riastrad 		 },
    412  1.1  riastrad 		{
    413  1.1  riastrad 		 .addr = dvo->slave_addr,
    414  1.1  riastrad 		 .flags = I2C_M_RD,
    415  1.1  riastrad 		 .len = 1,
    416  1.1  riastrad 		 .buf = in_buf,
    417  1.1  riastrad 		 }
    418  1.1  riastrad 	};
    419  1.1  riastrad 
    420  1.1  riastrad 	out_buf[0] = addr;
    421  1.1  riastrad 	out_buf[1] = 0;
    422  1.1  riastrad 
    423  1.1  riastrad 	if (i2c_transfer(adapter, msgs, 2) == 2) {
    424  1.1  riastrad 		*ch = in_buf[0];
    425  1.1  riastrad 		return true;
    426  1.1  riastrad 	}
    427  1.1  riastrad 
    428  1.1  riastrad 	if (!ns->quiet) {
    429  1.1  riastrad 		DRM_DEBUG_KMS
    430  1.1  riastrad 		    ("Unable to read register 0x%02x from %s:0x%02x.\n", addr,
    431  1.1  riastrad 		     adapter->name, dvo->slave_addr);
    432  1.1  riastrad 	}
    433  1.1  riastrad 
    434  1.1  riastrad 	return false;
    435  1.1  riastrad }
    436  1.1  riastrad 
    437  1.1  riastrad /*
    438  1.1  riastrad ** Write a register to the ns2501.
    439  1.1  riastrad ** Returns true if successful, false otherwise.
    440  1.1  riastrad ** If it returns false, it might be wise to enable the
    441  1.1  riastrad ** DVO with the above function.
    442  1.1  riastrad */
    443  1.1  riastrad static bool ns2501_writeb(struct intel_dvo_device *dvo, int addr, u8 ch)
    444  1.1  riastrad {
    445  1.1  riastrad 	struct ns2501_priv *ns = dvo->dev_priv;
    446  1.1  riastrad 	struct i2c_adapter *adapter = dvo->i2c_bus;
    447  1.1  riastrad 	u8 out_buf[2];
    448  1.1  riastrad 
    449  1.1  riastrad 	struct i2c_msg msg = {
    450  1.1  riastrad 		.addr = dvo->slave_addr,
    451  1.1  riastrad 		.flags = 0,
    452  1.1  riastrad 		.len = 2,
    453  1.1  riastrad 		.buf = out_buf,
    454  1.1  riastrad 	};
    455  1.1  riastrad 
    456  1.1  riastrad 	out_buf[0] = addr;
    457  1.1  riastrad 	out_buf[1] = ch;
    458  1.1  riastrad 
    459  1.1  riastrad 	if (i2c_transfer(adapter, &msg, 1) == 1) {
    460  1.1  riastrad 		return true;
    461  1.1  riastrad 	}
    462  1.1  riastrad 
    463  1.1  riastrad 	if (!ns->quiet) {
    464  1.1  riastrad 		DRM_DEBUG_KMS("Unable to write register 0x%02x to %s:%d\n",
    465  1.1  riastrad 			      addr, adapter->name, dvo->slave_addr);
    466  1.1  riastrad 	}
    467  1.1  riastrad 
    468  1.1  riastrad 	return false;
    469  1.1  riastrad }
    470  1.1  riastrad 
    471  1.1  riastrad /* National Semiconductor 2501 driver for chip on i2c bus
    472  1.1  riastrad  * scan for the chip on the bus.
    473  1.1  riastrad  * Hope the VBIOS initialized the PLL correctly so we can
    474  1.1  riastrad  * talk to it. If not, it will not be seen and not detected.
    475  1.1  riastrad  * Bummer!
    476  1.1  riastrad  */
    477  1.1  riastrad static bool ns2501_init(struct intel_dvo_device *dvo,
    478  1.1  riastrad 			struct i2c_adapter *adapter)
    479  1.1  riastrad {
    480  1.1  riastrad 	/* this will detect the NS2501 chip on the specified i2c bus */
    481  1.1  riastrad 	struct ns2501_priv *ns;
    482  1.1  riastrad 	unsigned char ch;
    483  1.1  riastrad 
    484  1.1  riastrad 	ns = kzalloc(sizeof(struct ns2501_priv), GFP_KERNEL);
    485  1.1  riastrad 	if (ns == NULL)
    486  1.1  riastrad 		return false;
    487  1.1  riastrad 
    488  1.1  riastrad 	dvo->i2c_bus = adapter;
    489  1.1  riastrad 	dvo->dev_priv = ns;
    490  1.1  riastrad 	ns->quiet = true;
    491  1.1  riastrad 
    492  1.1  riastrad 	if (!ns2501_readb(dvo, NS2501_VID_LO, &ch))
    493  1.1  riastrad 		goto out;
    494  1.1  riastrad 
    495  1.1  riastrad 	if (ch != (NS2501_VID & 0xff)) {
    496  1.1  riastrad 		DRM_DEBUG_KMS("ns2501 not detected got %d: from %s Slave %d.\n",
    497  1.1  riastrad 			      ch, adapter->name, dvo->slave_addr);
    498  1.1  riastrad 		goto out;
    499  1.1  riastrad 	}
    500  1.1  riastrad 
    501  1.1  riastrad 	if (!ns2501_readb(dvo, NS2501_DID_LO, &ch))
    502  1.1  riastrad 		goto out;
    503  1.1  riastrad 
    504  1.1  riastrad 	if (ch != (NS2501_DID & 0xff)) {
    505  1.1  riastrad 		DRM_DEBUG_KMS("ns2501 not detected got %d: from %s Slave %d.\n",
    506  1.1  riastrad 			      ch, adapter->name, dvo->slave_addr);
    507  1.1  riastrad 		goto out;
    508  1.1  riastrad 	}
    509  1.1  riastrad 	ns->quiet = false;
    510  1.1  riastrad 
    511  1.1  riastrad 	DRM_DEBUG_KMS("init ns2501 dvo controller successfully!\n");
    512  1.1  riastrad 
    513  1.1  riastrad 	return true;
    514  1.1  riastrad 
    515  1.1  riastrad out:
    516  1.1  riastrad 	kfree(ns);
    517  1.1  riastrad 	return false;
    518  1.1  riastrad }
    519  1.1  riastrad 
    520  1.1  riastrad static enum drm_connector_status ns2501_detect(struct intel_dvo_device *dvo)
    521  1.1  riastrad {
    522  1.1  riastrad 	/*
    523  1.1  riastrad 	 * This is a Laptop display, it doesn't have hotplugging.
    524  1.1  riastrad 	 * Even if not, the detection bit of the 2501 is unreliable as
    525  1.1  riastrad 	 * it only works for some display types.
    526  1.1  riastrad 	 * It is even more unreliable as the PLL must be active for
    527  1.1  riastrad 	 * allowing reading from the chiop.
    528  1.1  riastrad 	 */
    529  1.1  riastrad 	return connector_status_connected;
    530  1.1  riastrad }
    531  1.1  riastrad 
    532  1.1  riastrad static enum drm_mode_status ns2501_mode_valid(struct intel_dvo_device *dvo,
    533  1.1  riastrad 					      struct drm_display_mode *mode)
    534  1.1  riastrad {
    535  1.1  riastrad 	DRM_DEBUG_KMS
    536  1.1  riastrad 	    ("is mode valid (hdisplay=%d,htotal=%d,vdisplay=%d,vtotal=%d)\n",
    537  1.1  riastrad 	     mode->hdisplay, mode->htotal, mode->vdisplay, mode->vtotal);
    538  1.1  riastrad 
    539  1.1  riastrad 	/*
    540  1.1  riastrad 	 * Currently, these are all the modes I have data from.
    541  1.1  riastrad 	 * More might exist. Unclear how to find the native resolution
    542  1.1  riastrad 	 * of the panel in here so we could always accept it
    543  1.1  riastrad 	 * by disabling the scaler.
    544  1.1  riastrad 	 */
    545  1.1  riastrad 	if ((mode->hdisplay == 640 && mode->vdisplay == 480 && mode->clock == 25175) ||
    546  1.1  riastrad 	    (mode->hdisplay == 800 && mode->vdisplay == 600 && mode->clock == 40000) ||
    547  1.1  riastrad 	    (mode->hdisplay == 1024 && mode->vdisplay == 768 && mode->clock == 65000)) {
    548  1.1  riastrad 		return MODE_OK;
    549  1.1  riastrad 	} else {
    550  1.1  riastrad 		return MODE_ONE_SIZE;	/* Is this a reasonable error? */
    551  1.1  riastrad 	}
    552  1.1  riastrad }
    553  1.1  riastrad 
    554  1.1  riastrad static void ns2501_mode_set(struct intel_dvo_device *dvo,
    555  1.1  riastrad 			    const struct drm_display_mode *mode,
    556  1.1  riastrad 			    const struct drm_display_mode *adjusted_mode)
    557  1.1  riastrad {
    558  1.1  riastrad 	const struct ns2501_configuration *conf;
    559  1.1  riastrad 	struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv);
    560  1.1  riastrad 	int mode_idx, i;
    561  1.1  riastrad 
    562  1.1  riastrad 	DRM_DEBUG_KMS
    563  1.1  riastrad 	    ("set mode (hdisplay=%d,htotal=%d,vdisplay=%d,vtotal=%d).\n",
    564  1.1  riastrad 	     mode->hdisplay, mode->htotal, mode->vdisplay, mode->vtotal);
    565  1.1  riastrad 
    566  1.1  riastrad 	DRM_DEBUG_KMS("Detailed requested mode settings are:\n"
    567  1.1  riastrad 			"clock		: %d kHz\n"
    568  1.1  riastrad 			"hdisplay	: %d\n"
    569  1.1  riastrad 			"hblank start	: %d\n"
    570  1.1  riastrad 			"hblank end	: %d\n"
    571  1.1  riastrad 			"hsync start	: %d\n"
    572  1.1  riastrad 			"hsync end	: %d\n"
    573  1.1  riastrad 			"htotal		: %d\n"
    574  1.1  riastrad 			"hskew		: %d\n"
    575  1.1  riastrad 			"vdisplay	: %d\n"
    576  1.1  riastrad 			"vblank start	: %d\n"
    577  1.1  riastrad 			"hblank end	: %d\n"
    578  1.1  riastrad 			"vsync start	: %d\n"
    579  1.1  riastrad 			"vsync end	: %d\n"
    580  1.1  riastrad 			"vtotal		: %d\n",
    581  1.1  riastrad 			adjusted_mode->crtc_clock,
    582  1.1  riastrad 			adjusted_mode->crtc_hdisplay,
    583  1.1  riastrad 			adjusted_mode->crtc_hblank_start,
    584  1.1  riastrad 			adjusted_mode->crtc_hblank_end,
    585  1.1  riastrad 			adjusted_mode->crtc_hsync_start,
    586  1.1  riastrad 			adjusted_mode->crtc_hsync_end,
    587  1.1  riastrad 			adjusted_mode->crtc_htotal,
    588  1.1  riastrad 			adjusted_mode->crtc_hskew,
    589  1.1  riastrad 			adjusted_mode->crtc_vdisplay,
    590  1.1  riastrad 			adjusted_mode->crtc_vblank_start,
    591  1.1  riastrad 			adjusted_mode->crtc_vblank_end,
    592  1.1  riastrad 			adjusted_mode->crtc_vsync_start,
    593  1.1  riastrad 			adjusted_mode->crtc_vsync_end,
    594  1.1  riastrad 			adjusted_mode->crtc_vtotal);
    595  1.1  riastrad 
    596  1.1  riastrad 	if (mode->hdisplay == 640 && mode->vdisplay == 480)
    597  1.1  riastrad 		mode_idx = MODE_640x480;
    598  1.1  riastrad 	else if (mode->hdisplay == 800 && mode->vdisplay == 600)
    599  1.1  riastrad 		mode_idx = MODE_800x600;
    600  1.1  riastrad 	else if (mode->hdisplay == 1024 && mode->vdisplay == 768)
    601  1.1  riastrad 		mode_idx = MODE_1024x768;
    602  1.1  riastrad 	else
    603  1.1  riastrad 		return;
    604  1.1  riastrad 
    605  1.1  riastrad 	/* Hopefully doing it every time won't hurt... */
    606  1.1  riastrad 	for (i = 0; i < ARRAY_SIZE(regs_init); i++)
    607  1.1  riastrad 		ns2501_writeb(dvo, regs_init[i].offset, regs_init[i].value);
    608  1.1  riastrad 
    609  1.1  riastrad 	/* Write the mode-agnostic values */
    610  1.1  riastrad 	for (i = 0; i < ARRAY_SIZE(mode_agnostic_values); i++)
    611  1.1  riastrad 		ns2501_writeb(dvo, mode_agnostic_values[i].offset,
    612  1.1  riastrad 				mode_agnostic_values[i].value);
    613  1.1  riastrad 
    614  1.1  riastrad 	/* Write now the mode-specific configuration */
    615  1.1  riastrad 	conf = ns2501_modes + mode_idx;
    616  1.1  riastrad 	ns->conf = conf;
    617  1.1  riastrad 
    618  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG8, conf->conf);
    619  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG1B, conf->pll_a);
    620  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG1C, conf->pll_b & 0xff);
    621  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG1D, conf->pll_b >> 8);
    622  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGC1, conf->hstart & 0xff);
    623  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGC2, conf->hstart >> 8);
    624  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGC3, conf->hstop & 0xff);
    625  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGC4, conf->hstop >> 8);
    626  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGC5, conf->vstart & 0xff);
    627  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGC6, conf->vstart >> 8);
    628  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGC7, conf->vstop & 0xff);
    629  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGC8, conf->vstop >> 8);
    630  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG80, conf->vsync & 0xff);
    631  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG81, conf->vsync >> 8);
    632  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG82, conf->vtotal & 0xff);
    633  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG83, conf->vtotal >> 8);
    634  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG98, conf->hpos & 0xff);
    635  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG99, conf->hpos >> 8);
    636  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG8E, conf->vpos & 0xff);
    637  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG8F, conf->vpos >> 8);
    638  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG9C, conf->voffs & 0xff);
    639  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG9D, conf->voffs >> 8);
    640  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGB8, conf->hscale & 0xff);
    641  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGB9, conf->hscale >> 8);
    642  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG10, conf->vscale & 0xff);
    643  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG11, conf->vscale >> 8);
    644  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGF9, conf->dither);
    645  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REG41, conf->syncb);
    646  1.1  riastrad 	ns2501_writeb(dvo, NS2501_REGC0, conf->sync);
    647  1.1  riastrad }
    648  1.1  riastrad 
    649  1.1  riastrad /* set the NS2501 power state */
    650  1.1  riastrad static bool ns2501_get_hw_state(struct intel_dvo_device *dvo)
    651  1.1  riastrad {
    652  1.1  riastrad 	unsigned char ch;
    653  1.1  riastrad 
    654  1.1  riastrad 	if (!ns2501_readb(dvo, NS2501_REG8, &ch))
    655  1.1  riastrad 		return false;
    656  1.1  riastrad 
    657  1.1  riastrad 	return ch & NS2501_8_PD;
    658  1.1  riastrad }
    659  1.1  riastrad 
    660  1.1  riastrad /* set the NS2501 power state */
    661  1.1  riastrad static void ns2501_dpms(struct intel_dvo_device *dvo, bool enable)
    662  1.1  riastrad {
    663  1.1  riastrad 	struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv);
    664  1.1  riastrad 
    665  1.1  riastrad 	DRM_DEBUG_KMS("Trying set the dpms of the DVO to %i\n", enable);
    666  1.1  riastrad 
    667  1.1  riastrad 	if (enable) {
    668  1.1  riastrad 		ns2501_writeb(dvo, NS2501_REGC0, ns->conf->sync | 0x08);
    669  1.1  riastrad 
    670  1.1  riastrad 		ns2501_writeb(dvo, NS2501_REG41, ns->conf->syncb);
    671  1.1  riastrad 
    672  1.1  riastrad 		ns2501_writeb(dvo, NS2501_REG34, NS2501_34_ENABLE_OUTPUT);
    673  1.1  riastrad 		msleep(15);
    674  1.1  riastrad 
    675  1.1  riastrad 		ns2501_writeb(dvo, NS2501_REG8,
    676  1.1  riastrad 				ns->conf->conf | NS2501_8_BPAS);
    677  1.1  riastrad 		if (!(ns->conf->conf & NS2501_8_BPAS))
    678  1.1  riastrad 			ns2501_writeb(dvo, NS2501_REG8, ns->conf->conf);
    679  1.1  riastrad 		msleep(200);
    680  1.1  riastrad 
    681  1.1  riastrad 		ns2501_writeb(dvo, NS2501_REG34,
    682  1.1  riastrad 			NS2501_34_ENABLE_OUTPUT | NS2501_34_ENABLE_BACKLIGHT);
    683  1.1  riastrad 
    684  1.1  riastrad 		ns2501_writeb(dvo, NS2501_REGC0, ns->conf->sync);
    685  1.1  riastrad 	} else {
    686  1.1  riastrad 		ns2501_writeb(dvo, NS2501_REG34, NS2501_34_ENABLE_OUTPUT);
    687  1.1  riastrad 		msleep(200);
    688  1.1  riastrad 
    689  1.1  riastrad 		ns2501_writeb(dvo, NS2501_REG8, NS2501_8_VEN | NS2501_8_HEN |
    690  1.1  riastrad 				NS2501_8_BPAS);
    691  1.1  riastrad 		msleep(15);
    692  1.1  riastrad 
    693  1.1  riastrad 		ns2501_writeb(dvo, NS2501_REG34, 0x00);
    694  1.1  riastrad 	}
    695  1.1  riastrad }
    696  1.1  riastrad 
    697  1.1  riastrad static void ns2501_destroy(struct intel_dvo_device *dvo)
    698  1.1  riastrad {
    699  1.1  riastrad 	struct ns2501_priv *ns = dvo->dev_priv;
    700  1.1  riastrad 
    701  1.1  riastrad 	if (ns) {
    702  1.1  riastrad 		kfree(ns);
    703  1.1  riastrad 		dvo->dev_priv = NULL;
    704  1.1  riastrad 	}
    705  1.1  riastrad }
    706  1.1  riastrad 
    707  1.1  riastrad const struct intel_dvo_dev_ops ns2501_ops = {
    708  1.1  riastrad 	.init = ns2501_init,
    709  1.1  riastrad 	.detect = ns2501_detect,
    710  1.1  riastrad 	.mode_valid = ns2501_mode_valid,
    711  1.1  riastrad 	.mode_set = ns2501_mode_set,
    712  1.1  riastrad 	.dpms = ns2501_dpms,
    713  1.1  riastrad 	.get_hw_state = ns2501_get_hw_state,
    714  1.1  riastrad 	.destroy = ns2501_destroy,
    715  1.1  riastrad };
    716