The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/ibm561.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: ibm561.c,v 1.8 2008/04/28 20:23:50 martin Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Roland C. Dowdeswell of Ponte, Inc.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 #include <sys/cdefs.h>
   33 __KERNEL_RCSID(0, "$NetBSD: ibm561.c,v 1.8 2008/04/28 20:23:50 martin Exp $");
   34 
   35 #include <sys/param.h>
   36 #include <sys/systm.h>
   37 #include <sys/device.h>
   38 #include <sys/buf.h>
   39 #include <sys/kernel.h>
   40 #include <sys/malloc.h>
   41 
   42 #include <uvm/uvm_extern.h>
   43 
   44 #include <dev/pci/pcivar.h>
   45 #include <dev/ic/ibm561reg.h>
   46 #include <dev/ic/ibm561var.h>
   47 #include <dev/ic/ramdac.h>
   48 
   49 #include <dev/wscons/wsconsio.h>
   50 
   51 /*
   52  * Functions exported via the RAMDAC configuration table.
   53  */
   54 void    ibm561_init(struct ramdac_cookie *);
   55 int     ibm561_set_cmap(struct ramdac_cookie *, struct wsdisplay_cmap *);
   56 int     ibm561_get_cmap(struct ramdac_cookie *, struct wsdisplay_cmap *);
   57 int     ibm561_set_cursor(struct ramdac_cookie *, struct wsdisplay_cursor *);
   58 int     ibm561_get_cursor(struct ramdac_cookie *, struct wsdisplay_cursor *);
   59 int     ibm561_set_curpos(struct ramdac_cookie *, struct wsdisplay_curpos *);
   60 int     ibm561_get_curpos(struct ramdac_cookie *, struct wsdisplay_curpos *);
   61 int     ibm561_get_curmax(struct ramdac_cookie *, struct wsdisplay_curpos *);
   62 int     ibm561_set_dotclock(struct ramdac_cookie *, unsigned);
   63 
   64 /* XXX const */
   65 struct ramdac_funcs ibm561_funcsstruct = {
   66         "IBM561",
   67         ibm561_register,
   68         ibm561_init,
   69         ibm561_set_cmap,
   70         ibm561_get_cmap,
   71         ibm561_set_cursor,
   72         ibm561_get_cursor,
   73         ibm561_set_curpos,
   74         ibm561_get_curpos,
   75         ibm561_get_curmax,
   76         NULL,                   /* check_curcmap; not needed */
   77         NULL,                   /* set_curcmap; not needed */
   78         NULL,                   /* get_curcmap; not needed */
   79         ibm561_set_dotclock,
   80 };
   81 
   82 /*
   83  * Private data.
   84  */
   85 struct ibm561data {
   86         void            *cookie;
   87 
   88         int             (*ramdac_sched_update)(void *, void (*)(void *));
   89         void            (*ramdac_wr)(void *, u_int, u_int8_t);
   90         u_int8_t        (*ramdac_rd)(void *, u_int);
   91 
   92 #define CHANGED_CURCMAP         0x0001  /* cursor cmap */
   93 #define CHANGED_CMAP            0x0002  /* color map */
   94 #define CHANGED_WTYPE           0x0004  /* window types */
   95 #define CHANGED_DOTCLOCK        0x0008  /* dot clock */
   96 #define CHANGED_ALL             0x000f  /* or of all above */
   97         u_int8_t        changed;
   98 
   99         /* dotclock parameters */
  100         u_int8_t        vco_div;
  101         u_int8_t        pll_ref;
  102         u_int8_t        div_dotclock;
  103 
  104         /* colormaps et al. */
  105         u_int8_t        curcmap_r[2];
  106         u_int8_t        curcmap_g[2];
  107         u_int8_t        curcmap_b[2];
  108 
  109         u_int8_t        cmap_r[IBM561_NCMAP_ENTRIES];
  110         u_int8_t        cmap_g[IBM561_NCMAP_ENTRIES];
  111         u_int8_t        cmap_b[IBM561_NCMAP_ENTRIES];
  112 
  113         u_int16_t       gamma_r[IBM561_NGAMMA_ENTRIES];
  114         u_int16_t       gamma_g[IBM561_NGAMMA_ENTRIES];
  115         u_int16_t       gamma_b[IBM561_NGAMMA_ENTRIES];
  116 
  117         u_int16_t       wtype[IBM561_NWTYPES];
  118 };
  119 
  120 /*
  121  * private functions
  122  */
  123 void    ibm561_update(void *);
  124 static void ibm561_load_cmap(struct ibm561data *);
  125 static void ibm561_load_dotclock(struct ibm561data *);
  126 static void ibm561_regbegin(struct ibm561data *, u_int16_t);
  127 static void ibm561_regcont(struct ibm561data *, u_int16_t, u_int8_t);
  128 static void ibm561_regcont10bit(struct ibm561data *, u_int16_t, u_int16_t);
  129 static void ibm561_regwr(struct ibm561data *, u_int16_t, u_int8_t);
  130 
  131 struct ramdac_funcs *
  132 ibm561_funcs(void)
  133 {
  134         return &ibm561_funcsstruct;
  135 }
  136 
  137 struct ramdac_cookie *
  138 ibm561_register(v, sched_update, wr, rd)
  139         void *v;
  140         int (*sched_update)(void *, void (*)(void *));
  141         void (*wr)(void *, u_int, u_int8_t);
  142         u_int8_t (*rd)(void *, u_int);
  143 {
  144         struct ibm561data *data;
  145 
  146         data = malloc(sizeof *data, M_DEVBUF, M_WAITOK|M_ZERO);
  147         data->cookie = v;
  148         data->ramdac_sched_update = sched_update;
  149         data->ramdac_wr = wr;
  150         data->ramdac_rd = rd;
  151         return (struct ramdac_cookie *)data;
  152 }
  153 
  154 /*
  155  * This function exists solely to provide a means to init
  156  * the RAMDAC without first registering.  It is useful for
  157  * initializing the console early on.
  158  */
  159 
  160 struct ibm561data *saved_console_data;
  161 
  162 void
  163 ibm561_cninit(v, sched_update, wr, rd, dotclock)
  164         void *v;
  165         int (*sched_update)(void *, void (*)(void *));
  166         void (*wr)(void *, u_int, u_int8_t);
  167         u_int8_t (*rd)(void *, u_int);
  168         u_int dotclock;
  169 {
  170         struct ibm561data tmp, *data = &tmp;
  171         memset(data, 0x0, sizeof *data);
  172         data->cookie = v;
  173         data->ramdac_sched_update = sched_update;
  174         data->ramdac_wr = wr;
  175         data->ramdac_rd = rd;
  176         ibm561_set_dotclock((struct ramdac_cookie *)data, dotclock);
  177         saved_console_data = data;
  178         ibm561_init((struct ramdac_cookie *)data);
  179         saved_console_data = NULL;
  180 }
  181 
  182 void
  183 ibm561_init(rc)
  184         struct ramdac_cookie *rc;
  185 {
  186         struct  ibm561data *data = (struct ibm561data *)rc;
  187         int     i;
  188 
  189         /* XXX this is _essential_ */
  190 
  191         ibm561_load_dotclock(data);
  192 
  193         /* XXXrcd: bunch of magic of which I have no current clue */
  194         ibm561_regwr(data, IBM561_CONFIG_REG1, 0x2a);
  195         ibm561_regwr(data, IBM561_CONFIG_REG3, 0x41);
  196         ibm561_regwr(data, IBM561_CONFIG_REG4, 0x20);
  197 
  198         /* initialize the card a bit */
  199         ibm561_regwr(data, IBM561_SYNC_CNTL, 0x1);
  200         ibm561_regwr(data, IBM561_CONFIG_REG2, 0x19);
  201 
  202         ibm561_regwr(data, IBM561_CONFIG_REG1, 0x2a);
  203         ibm561_regwr(data, IBM561_CONFIG_REG4, 0x20);
  204 
  205         ibm561_regbegin(data, IBM561_WAT_SEG_REG);
  206         ibm561_regcont(data, IBM561_CMD, 0x00);
  207         ibm561_regcont(data, IBM561_CMD, 0x00);
  208         ibm561_regcont(data, IBM561_CMD, 0x00);
  209         ibm561_regcont(data, IBM561_CMD, 0x00);
  210         ibm561_regbegin(data, IBM561_CHROMAKEY0);
  211         ibm561_regcont(data, IBM561_CMD, 0x00);
  212         ibm561_regcont(data, IBM561_CMD, 0x00);
  213         ibm561_regcont(data, IBM561_CMD, 0x00);
  214         ibm561_regcont(data, IBM561_CMD, 0x00);
  215 
  216         ibm561_regwr(data, IBM561_CURS_CNTL_REG, 0x00); /* XXX off? */
  217 
  218         /* cursor `hot spot' registers */
  219         ibm561_regbegin(data, IBM561_HOTSPOT_REG);
  220         ibm561_regcont(data, IBM561_CMD, 0x00);
  221         ibm561_regcont(data, IBM561_CMD, 0x00);
  222         ibm561_regcont(data, IBM561_CMD, 0xff);
  223         ibm561_regcont(data, IBM561_CMD, 0x00);
  224         ibm561_regcont(data, IBM561_CMD, 0xff);
  225         ibm561_regcont(data, IBM561_CMD, 0x00);
  226 
  227         /* VRAM Mask Registers (diagnostics) */
  228         ibm561_regbegin(data, IBM561_VRAM_MASK_REG);
  229         ibm561_regcont(data, IBM561_CMD, 0xff);
  230         ibm561_regcont(data, IBM561_CMD, 0xff);
  231         ibm561_regcont(data, IBM561_CMD, 0xff);
  232         ibm561_regcont(data, IBM561_CMD, 0xff);
  233         ibm561_regcont(data, IBM561_CMD, 0xff);
  234         ibm561_regcont(data, IBM561_CMD, 0xff);
  235         ibm561_regcont(data, IBM561_CMD, 0xff);
  236 
  237         /* let's set up some decent default colour maps and gammas */
  238         for (i=0; i < IBM561_NCMAP_ENTRIES; i++)
  239                 data->cmap_r[i] = data->cmap_g[i] = data->cmap_b[i] = 0xff;
  240         data->cmap_r[0]   = data->cmap_g[0]   = data->cmap_b[0]   = 0x00;
  241         data->cmap_r[256] = data->cmap_g[256] = data->cmap_b[256] = 0x00;
  242         data->cmap_r[512] = data->cmap_g[512] = data->cmap_b[512] = 0x00;
  243         data->cmap_r[768] = data->cmap_g[768] = data->cmap_b[768] = 0x00;
  244 
  245         data->gamma_r[0] = data->gamma_g[0] = data->gamma_b[0] = 0x00;
  246         for (i=0; i < IBM561_NGAMMA_ENTRIES; i++)
  247                 data->gamma_r[i] = data->gamma_g[i] = data->gamma_b[i] = 0xff;
  248 
  249         for (i=0; i < IBM561_NWTYPES; i++)
  250                 data->wtype[i] = 0x0036;
  251         data->wtype[1] = 0x0028;
  252 
  253         /* the last step: */
  254         data->changed = CHANGED_ALL;
  255         data->ramdac_sched_update(data->cookie, ibm561_update);
  256 }
  257 
  258 int
  259 ibm561_set_cmap(rc, cmapp)
  260         struct ramdac_cookie *rc;
  261         struct wsdisplay_cmap *cmapp;
  262 {
  263         struct ibm561data *data = (struct ibm561data *)rc;
  264         u_int count, index;
  265         uint8_t r[IBM561_NCMAP_ENTRIES];
  266         uint8_t g[IBM561_NCMAP_ENTRIES];
  267         uint8_t b[IBM561_NCMAP_ENTRIES];
  268         int s, error;
  269 
  270         if (cmapp->index >= IBM561_NCMAP_ENTRIES ||
  271             cmapp->count > IBM561_NCMAP_ENTRIES - cmapp->index)
  272                 return (EINVAL);
  273 
  274         index = cmapp->index;
  275         count = cmapp->count;
  276         error = copyin(cmapp->red, &r[index], count);
  277         if (error)
  278                 return error;
  279         error = copyin(cmapp->green, &g[index], count);
  280         if (error)
  281                 return error;
  282         error = copyin(cmapp->blue, &b[index], count);
  283         if (error)
  284                 return error;
  285         s = spltty();
  286         memcpy(&data->cmap_r[index], &r[index], count);
  287         memcpy(&data->cmap_g[index], &g[index], count);
  288         memcpy(&data->cmap_b[index], &b[index], count);
  289         data->changed |= CHANGED_CMAP;
  290         data->ramdac_sched_update(data->cookie, ibm561_update);
  291         splx(s);
  292         return (0);
  293 }
  294 
  295 int
  296 ibm561_get_cmap(rc, cmapp)
  297         struct ramdac_cookie *rc;
  298         struct wsdisplay_cmap *cmapp;
  299 {
  300         struct ibm561data *data = (struct ibm561data *)rc;
  301         u_int count, index;
  302         int error;
  303 
  304         if (cmapp->index >= IBM561_NCMAP_ENTRIES ||
  305             cmapp->count > IBM561_NCMAP_ENTRIES - cmapp->index)
  306                 return (EINVAL);
  307         count = cmapp->count;
  308         index = cmapp->index;
  309         error = copyout(&data->cmap_r[index], cmapp->red, count);
  310         if (error)
  311                 return (error);
  312         error = copyout(&data->cmap_g[index], cmapp->green, count);
  313         if (error)
  314                 return (error);
  315         error = copyout(&data->cmap_b[index], cmapp->blue, count);
  316         return (error);
  317 }
  318 
  319 /*
  320  * XXX:
  321  *  I am leaving these functions returning EINVAL, as they are
  322  *  not strictly necessary for the correct functioning of the
  323  *  card and in fact are not used on the other TGA variants, except
  324  *  they are exported via ioctl(2) to userland, which does not in
  325  *  fact use them.
  326  */
  327 
  328 int
  329 ibm561_set_cursor(rc, cursorp)
  330         struct ramdac_cookie *rc;
  331         struct wsdisplay_cursor *cursorp;
  332 {
  333         return EINVAL;
  334 }
  335 
  336 int
  337 ibm561_get_cursor(rc, cursorp)
  338         struct ramdac_cookie *rc;
  339         struct wsdisplay_cursor *cursorp;
  340 {
  341         return EINVAL;
  342 }
  343 
  344 int
  345 ibm561_set_curpos(rc, curposp)
  346         struct ramdac_cookie *rc;
  347         struct wsdisplay_curpos *curposp;
  348 {
  349         return EINVAL;
  350 }
  351 
  352 int
  353 ibm561_get_curpos(rc, curposp)
  354         struct ramdac_cookie *rc;
  355         struct wsdisplay_curpos *curposp;
  356 {
  357         return EINVAL;
  358 }
  359 
  360 int
  361 ibm561_get_curmax(rc, curposp)
  362         struct ramdac_cookie *rc;
  363         struct wsdisplay_curpos *curposp;
  364 {
  365         return EINVAL;
  366 }
  367 
  368 int
  369 ibm561_set_dotclock(rc, dotclock)
  370         struct ramdac_cookie *rc;
  371         unsigned dotclock;
  372 {
  373         struct ibm561data *data = (struct ibm561data *)rc;
  374 
  375         /* XXXrcd:  a couple of these are a little hazy, vis a vis
  376          *          check 175MHz and 202MHz, which are wrong...
  377          */
  378         switch (dotclock) {
  379         case  25175000: data->vco_div = 0x3e; data->pll_ref = 0x09; break;
  380         case  31500000: data->vco_div = 0x17; data->pll_ref = 0x05; break;
  381         case  40000000: data->vco_div = 0x42; data->pll_ref = 0x06; break;
  382         case  50000000: data->vco_div = 0x45; data->pll_ref = 0x05; break;
  383         case  65000000: data->vco_div = 0xac; data->pll_ref = 0x0c; break;
  384         case  69000000: data->vco_div = 0xa9; data->pll_ref = 0x0b; break;
  385         case  74000000: data->vco_div = 0x9c; data->pll_ref = 0x09; break;
  386         case  75000000: data->vco_div = 0x93; data->pll_ref = 0x08; break;
  387         case 103994000: data->vco_div = 0x96; data->pll_ref = 0x06; break;
  388         case 108180000: data->vco_div = 0xb8; data->pll_ref = 0x08; break;
  389         case 110000000: data->vco_div = 0xba; data->pll_ref = 0x08; break;
  390         case 119840000: data->vco_div = 0x82; data->pll_ref = 0x04; break;
  391         case 130808000: data->vco_div = 0xc8; data->pll_ref = 0x08; break;
  392         case 135000000: data->vco_div = 0xc1; data->pll_ref = 0x07; break;
  393         case 175000000: data->vco_div = 0xe2; data->pll_ref = 0x07; break;
  394         case 202500000: data->vco_div = 0xe2; data->pll_ref = 0x07; break;
  395         default:
  396                 return EINVAL;
  397         }
  398 
  399         data->div_dotclock = 0xb0;
  400         data->changed |= CHANGED_DOTCLOCK;
  401         return 0;
  402 }
  403 
  404 /*
  405  * Internal Functions
  406  */
  407 
  408 void
  409 ibm561_update(vp)
  410         void *vp;
  411 {
  412         struct ibm561data *data = (struct ibm561data *)vp;
  413         int     i;
  414 
  415         /* XXX see comment above ibm561_cninit() */
  416         if (!data)
  417                 data = saved_console_data;
  418 
  419         if (data->changed & CHANGED_WTYPE) {
  420                 ibm561_regbegin(data, IBM561_FB_WINTYPE);
  421                 for (i=0; i < IBM561_NWTYPES; i++)
  422                         ibm561_regcont10bit(data, IBM561_CMD_FB_WAT, data->wtype[i]);
  423 
  424                 /* XXXrcd:  quick hack here for AUX FB table */
  425                 ibm561_regbegin(data, IBM561_AUXFB_WINTYPE);
  426                 for (i=0; i < IBM561_NWTYPES; i++)
  427                         ibm561_regcont(data, IBM561_CMD, 0x04);
  428 
  429                 /* XXXrcd:  quick hack here for OL WAT table */
  430                 ibm561_regbegin(data, IBM561_OL_WINTYPE);
  431                 for (i=0; i < IBM561_NWTYPES; i++)
  432                         ibm561_regcont10bit(data, IBM561_CMD_FB_WAT, 0x0231);
  433 
  434                 /* XXXrcd:  quick hack here for AUX OL WAT table */
  435                 ibm561_regbegin(data, IBM561_AUXOL_WINTYPE);
  436                 for (i=0; i < IBM561_NWTYPES; i++)
  437                         ibm561_regcont(data, IBM561_CMD, 0x0c);
  438         }
  439 
  440         if (data->changed & CHANGED_CMAP)
  441                 ibm561_load_cmap(data);
  442 
  443         /* XXX:  I am not sure in what situations it is safe to
  444          *       change the dotclock---hope this is good.
  445          */
  446         if (data->changed & CHANGED_DOTCLOCK)
  447                 ibm561_load_dotclock(data);
  448 }
  449 
  450 static void
  451 ibm561_load_cmap(struct ibm561data *data)
  452 {
  453         int     i;
  454 
  455         ibm561_regbegin(data, IBM561_CMAP_TABLE);
  456         for (i=0; i < IBM561_NCMAP_ENTRIES; i++) {
  457                 ibm561_regcont(data, IBM561_CMD_CMAP, data->cmap_r[i]);
  458                 ibm561_regcont(data, IBM561_CMD_CMAP, data->cmap_g[i]);
  459                 ibm561_regcont(data, IBM561_CMD_CMAP, data->cmap_b[i]);
  460         }
  461 
  462         ibm561_regbegin(data, IBM561_RED_GAMMA_TABLE);
  463         for (i=0; i < 256; i++)
  464                 ibm561_regcont10bit(data, IBM561_CMD_GAMMA, data->gamma_r[i]);
  465 
  466         ibm561_regbegin(data, IBM561_GREEN_GAMMA_TABLE);
  467         for (i=1; i < 256; i++)
  468                 ibm561_regcont10bit(data, IBM561_CMD_GAMMA, data->gamma_g[i]);
  469 
  470         ibm561_regbegin(data, IBM561_BLUE_GAMMA_TABLE);
  471         for (i=1; i < 256; i++)
  472                 ibm561_regcont10bit(data, IBM561_CMD_GAMMA, data->gamma_b[i]);
  473 
  474 }
  475 
  476 static void
  477 ibm561_load_dotclock(struct ibm561data *data)
  478 {
  479         /* XXX
  480          * we should probably be more pro-active here, but it shouldn't
  481          * actually happen...
  482          */
  483         if (!data->vco_div || !data->pll_ref || ! data->div_dotclock) {
  484                 panic("ibm561_load_dotclock: called uninitialized");
  485         }
  486 
  487         ibm561_regwr(data, IBM561_PLL_VCO_DIV,  data->vco_div);
  488         ibm561_regwr(data, IBM561_PLL_REF_REG, data->pll_ref);
  489         ibm561_regwr(data, IBM561_DIV_DOTCLCK, data->div_dotclock);
  490 }
  491 
  492 static void
  493 ibm561_regcont10bit(struct ibm561data *data, u_int16_t reg, u_int16_t val)
  494 {
  495         data->ramdac_wr(data->cookie, IBM561_CMD_GAMMA, (val >> 2) & 0xff);
  496         data->ramdac_wr(data->cookie, IBM561_CMD_GAMMA, (val & 0x3) << 6);
  497 }
  498 
  499 static void
  500 ibm561_regbegin(struct ibm561data *data, u_int16_t reg)
  501 {
  502         data->ramdac_wr(data->cookie, IBM561_ADDR_LOW, reg & 0xff);
  503         data->ramdac_wr(data->cookie, IBM561_ADDR_HIGH, (reg >> 8) & 0xff);
  504 }
  505 
  506 static void
  507 ibm561_regcont(struct ibm561data *data, u_int16_t reg, u_int8_t val)
  508 {
  509         data->ramdac_wr(data->cookie, reg, val);
  510 }
  511 
  512 static void
  513 ibm561_regwr(struct ibm561data *data, u_int16_t reg, u_int8_t val)
  514 {
  515         ibm561_regbegin(data, reg);
  516         ibm561_regcont(data, IBM561_CMD, val);
  517 }

Cache object: 885c216f84886cc46680c1c049b1d9f1


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.