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

Cache object: 14965fdc4802cd4e395dc858fee7976e


[ 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.