[BACK]Return to plumvideo.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / hpcmips / dev

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/arch/hpcmips/dev/plumvideo.c between version 1.31 and 1.31.6.5

version 1.31, 2002/10/02 05:26:47 version 1.31.6.5, 2005/01/24 08:59:39
Line 36 
Line 36 
  * POSSIBILITY OF SUCH DAMAGE.   * POSSIBILITY OF SUCH DAMAGE.
  */   */
   
   #include <sys/cdefs.h>
   __KERNEL_RCSID(0, "$NetBSD$");
   
 #undef PLUMVIDEODEBUG  #undef PLUMVIDEODEBUG
   
 #include "plumohci.h" /* Plum2 OHCI shared memory allocated on V-RAM */  #include "plumohci.h" /* Plum2 OHCI shared memory allocated on V-RAM */
 #include "bivideo.h"  #include "bivideo.h"
   
Line 113  struct plumvideo_softc {
Line 117  struct plumvideo_softc {
 int     plumvideo_match(struct device*, struct cfdata*, void*);  int     plumvideo_match(struct device*, struct cfdata*, void*);
 void    plumvideo_attach(struct device*, struct device*, void*);  void    plumvideo_attach(struct device*, struct device*, void*);
   
 int     plumvideo_ioctl(void *, u_long, caddr_t, int, struct proc *);  int     plumvideo_ioctl(void *, u_long, caddr_t, int, struct lwp *);
 paddr_t plumvideo_mmap(void *, off_t, int);  paddr_t plumvideo_mmap(void *, off_t, int);
   
 CFATTACH_DECL(plumvideo, sizeof(struct plumvideo_softc),  CFATTACH_DECL(plumvideo, sizeof(struct plumvideo_softc),
Line 131  void plumvideo_hpcfbinit(struct plumvide
Line 135  void plumvideo_hpcfbinit(struct plumvide
 void    plumvideo_clut_default(struct plumvideo_softc *);  void    plumvideo_clut_default(struct plumvideo_softc *);
 void    plumvideo_clut_set(struct plumvideo_softc *, u_int32_t *, int, int);  void    plumvideo_clut_set(struct plumvideo_softc *, u_int32_t *, int, int);
 void    plumvideo_clut_get(struct plumvideo_softc *, u_int32_t *, int, int);  void    plumvideo_clut_get(struct plumvideo_softc *, u_int32_t *, int, int);
 void    __plumvideo_clut_access(struct plumvideo_softc *,  void    __plumvideo_clut_access(struct plumvideo_softc *, u_int32_t *, int, int,
             void (*)(bus_space_tag_t, bus_space_handle_t));              void (*)(bus_space_tag_t, bus_space_handle_t, u_int32_t *, int, int));
 static void _flush_cache(void) __attribute__((__unused__)); /* !!! */  static void _flush_cache(void) __attribute__((__unused__)); /* !!! */
   
 #ifdef PLUMVIDEODEBUG  #ifdef PLUMVIDEODEBUG
Line 416  plumvideo_init(struct plumvideo_softc *s
Line 420  plumvideo_init(struct plumvideo_softc *s
 }  }
   
 int  int
 plumvideo_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)  plumvideo_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct lwp *l)
 {  {
         struct plumvideo_softc *sc = (struct plumvideo_softc *)v;          struct plumvideo_softc *sc = (struct plumvideo_softc *)v;
         struct hpcfb_fbconf *fbconf;          struct hpcfb_fbconf *fbconf;
Line 429  plumvideo_ioctl(void *v, u_long cmd, cad
Line 433  plumvideo_ioctl(void *v, u_long cmd, cad
   
         switch (cmd) {          switch (cmd) {
         case WSDISPLAYIO_GETCMAP:          case WSDISPLAYIO_GETCMAP:
                 cmap = (struct wsdisplay_cmap*)data;                  cmap = (struct wsdisplay_cmap *)data;
                 cnt = cmap->count;                  cnt = cmap->count;
                 idx = cmap->index;                  idx = cmap->index;
   
                 if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||                  if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||
                     sc->sc_fbconf.hf_pack_width != 8 ||                      sc->sc_fbconf.hf_pack_width != 8 ||
                     !LEGAL_CLUT_INDEX(idx) ||                      !LEGAL_CLUT_INDEX(idx) ||
                     !LEGAL_CLUT_INDEX(idx + cnt -1)) {                      !LEGAL_CLUT_INDEX(idx + cnt - 1)) {
                         return (EINVAL);                          return (EINVAL);
                 }                  }
   
                 if (!uvm_useracc(cmap->red, cnt, B_WRITE) ||  
                     !uvm_useracc(cmap->green, cnt, B_WRITE) ||  
                     !uvm_useracc(cmap->blue, cnt, B_WRITE)) {  
                         return (EFAULT);  
                 }  
   
                 error = cmap_work_alloc(&r, &g, &b, &rgb, cnt);                  error = cmap_work_alloc(&r, &g, &b, &rgb, cnt);
                 if (error != 0) {                  if (error)
                         cmap_work_free(r, g, b, rgb);                          goto out;
                         return  (ENOMEM);  
                 }  
                 plumvideo_clut_get(sc, rgb, idx, cnt);                  plumvideo_clut_get(sc, rgb, idx, cnt);
                 rgb24_decompose(rgb, r, g, b, cnt);                  rgb24_decompose(rgb, r, g, b, cnt);
   
                 copyout(r, cmap->red, cnt);                  error = copyout(r, cmap->red, cnt);
                 copyout(g, cmap->green,cnt);                  if (error)
                 copyout(b, cmap->blue, cnt);                          goto out;
                   error = copyout(g, cmap->green, cnt);
                   if (error)
                           goto out;
                   error = copyout(b, cmap->blue, cnt);
   
   out:
                 cmap_work_free(r, g, b, rgb);                  cmap_work_free(r, g, b, rgb);
                   return error;
                 return (0);  
   
         case WSDISPLAYIO_PUTCMAP:          case WSDISPLAYIO_PUTCMAP:
                 cmap = (struct wsdisplay_cmap*)data;                  cmap = (struct wsdisplay_cmap *)data;
                 cnt = cmap->count;                  cnt = cmap->count;
                 idx = cmap->index;                  idx = cmap->index;
   
                 if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||                  if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||
                     sc->sc_fbconf.hf_pack_width != 8 ||                      sc->sc_fbconf.hf_pack_width != 8 ||
                     !LEGAL_CLUT_INDEX(idx) ||                      !LEGAL_CLUT_INDEX(idx) ||
                     !LEGAL_CLUT_INDEX(idx + cnt -1)) {                      !LEGAL_CLUT_INDEX(idx + cnt - 1)) {
                         return (EINVAL);                          return (EINVAL);
                 }                  }
   
                 if (!uvm_useracc(cmap->red, cnt, B_WRITE) ||  
                     !uvm_useracc(cmap->green, cnt, B_WRITE) ||  
                     !uvm_useracc(cmap->blue, cnt, B_WRITE)) {  
                         return (EFAULT);  
                 }  
   
                 error = cmap_work_alloc(&r, &g, &b, &rgb, cnt);                  error = cmap_work_alloc(&r, &g, &b, &rgb, cnt);
                 if (error != 0) {                  if (error)
                         cmap_work_free(r, g, b, rgb);                          goto out;
                         return  (ENOMEM);                  error = copyin(cmap->red, r, cnt);
                 }                  if (error)
                 copyin(cmap->red,   r, cnt);                          goto out;
                 copyin(cmap->green, g, cnt);                  error = copyin(cmap->green, g, cnt);
                 copyin(cmap->blue,  b, cnt);                  if (error)
                           goto out;
                   error = copyin(cmap->blue, b, cnt);
                   if (error)
                           goto out;
                 rgb24_compose(rgb, r, g, b, cnt);                  rgb24_compose(rgb, r, g, b, cnt);
                 plumvideo_clut_set(sc, rgb, idx, cnt);                  plumvideo_clut_set(sc, rgb, idx, cnt);
                   goto out;
                 cmap_work_free(r, g, b, rgb);  
   
                 return (0);  
   
         case HPCFBIO_GCONF:          case HPCFBIO_GCONF:
                 fbconf = (struct hpcfb_fbconf *)data;                  fbconf = (struct hpcfb_fbconf *)data;
Line 511  plumvideo_ioctl(void *v, u_long cmd, cad
Line 506  plumvideo_ioctl(void *v, u_long cmd, cad
                         return (EINVAL);                          return (EINVAL);
                 }                  }
                 /*                  /*
                  * nothing to do because we have only one configration                   * nothing to do because we have only one configuration
                  */                   */
                 return (0);                  return (0);
   
Line 536  plumvideo_ioctl(void *v, u_long cmd, cad
Line 531  plumvideo_ioctl(void *v, u_long cmd, cad
                 }                  }
                 /*                  /*
                  * nothing to do                   * nothing to do
                  * because we have only one unit and one configration                   * because we have only one unit and one configuration
                  */                   */
                 return (0);                  return (0);
   
Line 562  plumvideo_mmap(void *ctx, off_t offset, 
Line 557  plumvideo_mmap(void *ctx, off_t offset, 
         return (mips_btop(PLUM_VIDEO_VRAM_IOBASE_PHYSICAL + offset));          return (mips_btop(PLUM_VIDEO_VRAM_IOBASE_PHYSICAL + offset));
 }  }
   
   static void __plumvideo_clut_get(bus_space_tag_t, bus_space_handle_t,
       u_int32_t *, int, int);
   static void __plumvideo_clut_get(bus_space_tag_t iot, bus_space_handle_t ioh,
       u_int32_t *rgb, int beg, int cnt)
   {
           int i;
   
           for (i = 0, beg *= 4; i < cnt; i++, beg += 4) {
                   *rgb++ = bus_space_read_4(iot, ioh, beg) &
                       0x00ffffff;
           }
   }
   
 void  void
 plumvideo_clut_get(struct plumvideo_softc *sc, u_int32_t *rgb, int beg,  plumvideo_clut_get(struct plumvideo_softc *sc, u_int32_t *rgb, int beg,
     int cnt)      int cnt)
 {  {
         static void __plumvideo_clut_get(bus_space_tag_t,  
             bus_space_handle_t);  
         static void __plumvideo_clut_get(iot, ioh)  
             bus_space_tag_t iot;  
         bus_space_handle_t ioh;  
         {  
                 int i;  
   
                 for (i = 0, beg *= 4; i < cnt; i++, beg += 4) {  
                         *rgb++ = bus_space_read_4(iot, ioh, beg) &  
                             0x00ffffff;  
                 }  
         }  
   
         KASSERT(rgb);          KASSERT(rgb);
         KASSERT(LEGAL_CLUT_INDEX(beg));          KASSERT(LEGAL_CLUT_INDEX(beg));
         KASSERT(LEGAL_CLUT_INDEX(beg + cnt - 1));          KASSERT(LEGAL_CLUT_INDEX(beg + cnt - 1));
         __plumvideo_clut_access(sc, __plumvideo_clut_get);          __plumvideo_clut_access(sc, rgb, beg, cnt, __plumvideo_clut_get);
   }
   
   static void __plumvideo_clut_set(bus_space_tag_t, bus_space_handle_t,
       u_int32_t *, int, int);
   static void __plumvideo_clut_set(bus_space_tag_t iot, bus_space_handle_t ioh,
       u_int32_t *rgb, int beg, int cnt)
   {
           int i;
   
           for (i = 0, beg *= 4; i < cnt; i++, beg +=4) {
                   bus_space_write_4(iot, ioh, beg,
                       *rgb++ & 0x00ffffff);
           }
 }  }
   
 void  void
 plumvideo_clut_set(struct plumvideo_softc *sc, u_int32_t *rgb, int beg,  plumvideo_clut_set(struct plumvideo_softc *sc, u_int32_t *rgb, int beg,
     int cnt)      int cnt)
 {  {
         static void __plumvideo_clut_set(bus_space_tag_t,  
             bus_space_handle_t);  
         static void __plumvideo_clut_set(iot, ioh)  
             bus_space_tag_t iot;  
         bus_space_handle_t ioh;  
         {  
                 int i;  
   
                 for (i = 0, beg *= 4; i < cnt; i++, beg +=4) {  
                         bus_space_write_4(iot, ioh, beg,  
                             *rgb++ & 0x00ffffff);  
                 }  
         }  
   
         KASSERT(rgb);          KASSERT(rgb);
         KASSERT(LEGAL_CLUT_INDEX(beg));          KASSERT(LEGAL_CLUT_INDEX(beg));
         KASSERT(LEGAL_CLUT_INDEX(beg + cnt - 1));          KASSERT(LEGAL_CLUT_INDEX(beg + cnt - 1));
         __plumvideo_clut_access(sc, __plumvideo_clut_set);          __plumvideo_clut_access(sc, rgb, beg, cnt, __plumvideo_clut_set);
 }  }
   
 void  static void __plumvideo_clut_default(bus_space_tag_t, bus_space_handle_t,
 plumvideo_clut_default(struct plumvideo_softc *sc)      u_int32_t *, int, int);
 {  static void __plumvideo_clut_default(bus_space_tag_t iot, bus_space_handle_t ioh,
         static void __plumvideo_clut_default(bus_space_tag_t,      u_int32_t *rgb, int beg, int cnt)
             bus_space_handle_t);  {
         static void __plumvideo_clut_default(iot, ioh)          static const u_int8_t compo6[6] = { 0, 51, 102, 153, 204, 255 };
             bus_space_tag_t iot;          static const u_int32_t ansi_color[16] = {
         bus_space_handle_t ioh;                  0x000000, 0xff0000, 0x00ff00, 0xffff00,
         {                  0x0000ff, 0xff00ff, 0x00ffff, 0xffffff,
                 static const u_int8_t compo6[6] = { 0, 51, 102, 153, 204, 255 };                  0x000000, 0x800000, 0x008000, 0x808000,
                 static const u_int32_t ansi_color[16] = {                  0x000080, 0x800080, 0x008080, 0x808080,
                         0x000000, 0xff0000, 0x00ff00, 0xffff00,          };
                         0x0000ff, 0xff00ff, 0x00ffff, 0xffffff,          int i, r, g, b;
                         0x000000, 0x800000, 0x008000, 0x808000,  
                         0x000080, 0x800080, 0x008080, 0x808080,          /* ANSI escape sequence */
                 };          for (i = 0; i < 16; i++) {
                 int i, r, g, b;                  bus_space_write_4(iot, ioh, i << 2, ansi_color[i]);
           }
                 /* ANSI escape sequence */          /* 16 - 31, gray scale */
                 for (i = 0; i < 16; i++) {          for ( ; i < 32; i++) {
                         bus_space_write_4(iot, ioh, i << 2, ansi_color[i]);                  int j = (i - 16) * 17;
                 }                  bus_space_write_4(iot, ioh, i << 2, RGB24(j, j, j));
                 /* 16 - 31, gray scale */          }
                 for ( ; i < 32; i++) {          /* 32 - 247, RGB color */
                         int j = (i - 16) * 17;          for (r = 0; r < 6; r++) {
                         bus_space_write_4(iot, ioh, i << 2, RGB24(j, j, j));                  for (g = 0; g < 6; g++) {
                 }                          for (b = 0; b < 6; b++) {
                 /* 32 - 247, RGB color */                                  bus_space_write_4(iot, ioh, i << 2,
                 for (r = 0; r < 6; r++) {                                      RGB24(compo6[r],
                         for (g = 0; g < 6; g++) {                                          compo6[g],
                                 for (b = 0; b < 6; b++) {                                          compo6[b]));
                                         bus_space_write_4(iot, ioh, i << 2,                                  i++;
                                             RGB24(compo6[r],  
                                                 compo6[g],  
                                                 compo6[b]));  
                                         i++;  
                                 }  
                         }                          }
                 }                  }
                 /* 248 - 245, just white */  
                 for ( ; i < 256; i++) {  
                         bus_space_write_4(iot, ioh, i << 2, 0xffffff);  
                 }  
         }          }
           /* 248 - 245, just white */
           for ( ; i < 256; i++) {
                   bus_space_write_4(iot, ioh, i << 2, 0xffffff);
           }
   }
   
         __plumvideo_clut_access(sc, __plumvideo_clut_default);  void
   plumvideo_clut_default(struct plumvideo_softc *sc)
   {
           __plumvideo_clut_access(sc, NULL, 0, 256, __plumvideo_clut_default);
 }  }
   
 void  void
 __plumvideo_clut_access(struct plumvideo_softc *sc, void (*palette_func)  __plumvideo_clut_access(struct plumvideo_softc *sc, u_int32_t *rgb, int beg,
     (bus_space_tag_t, bus_space_handle_t))      int cnt, void (*palette_func)(bus_space_tag_t, bus_space_handle_t,
       u_int32_t *, int, int))
 {  {
         bus_space_tag_t regt = sc->sc_regt;          bus_space_tag_t regt = sc->sc_regt;
         bus_space_handle_t regh = sc->sc_regh;          bus_space_handle_t regh = sc->sc_regh;
Line 681  __plumvideo_clut_access(struct plumvideo
Line 674  __plumvideo_clut_access(struct plumvideo
         bus_space_write_4(regt, regh, PLUM_VIDEO_PLGMD_REG, val);          bus_space_write_4(regt, regh, PLUM_VIDEO_PLGMD_REG, val);
   
         /* palette access */          /* palette access */
         (*palette_func) (sc->sc_clutiot, sc->sc_clutioh);          (*palette_func) (sc->sc_clutiot, sc->sc_clutioh, rgb, beg, cnt);
   
         /* change palette mode to Display */          /* change palette mode to Display */
         val |= PLUM_VIDEO_PLGMD_MODE_DISPLAY;          val |= PLUM_VIDEO_PLGMD_MODE_DISPLAY;

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.31.6.5

CVSweb <webmaster@jp.NetBSD.org>