1 /* $Id: bt458.h,v 1.1 2007/01/07 23:22:21 fredette Exp $ */
2 
3 /* tme/ic/bt458.h - public header file for Brooktree Bt458 (and TI TLC34058) emulation */
4 
5 /*
6  * Copyright (c) 2006 Matt Fredette
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Matt Fredette.
20  * 4. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _TME_IC_BT458_H
37 #define _TME_IC_BT458_H
38 
39 #include <tme/common.h>
40 _TME_RCSID("$Id: bt458.h,v 1.1 2007/01/07 23:22:21 fredette Exp $");
41 
42 /* macros: */
43 
44 /* the bt458 control register addresses: */
45 #define TME_BT458_REG_CONTROL_MASK_READ		(0x04)
46 #define TME_BT458_REG_CONTROL_MASK_BLINK	(0x05)
47 #define TME_BT458_REG_CONTROL_COMMAND		(0x06)
48 #define TME_BT458_REG_CONTROL_TEST		(0x07)
49 
50 #define TME_BT458_REG_CONTROL_FIRST		(TME_BT458_REG_CONTROL_MASK_READ)
51 #define TME_BT458_REG_CONTROL_LAST		(TME_BT458_REG_CONTROL_TEST)
52 
53 /* the bt458 command register: */
54 #define TME_BT458_COMMAND_5PIXELS		TME_BIT(7)
55 #define TME_BT458_COMMAND_ENABLE_PALETTE	TME_BIT(6)
56 #define TME_BT458_COMMAND_BLINK_RATE_MASK	(0x30)
57 #define  TME_BT458_COMMAND_BLINK_RATE_16_48	 (0x00)
58 #define  TME_BT458_COMMAND_BLINK_RATE_16_16	 (0x10)
59 #define  TME_BT458_COMMAND_BLINK_RATE_32_32	 (0x20)
60 #define  TME_BT458_COMMAND_BLINK_RATE_64_64	 (0x30)
61 #define TME_BT458_COMMAND_ENABLE_BLINK_OL1	TME_BIT(3)
62 #define TME_BT458_COMMAND_ENABLE_BLINK_OL0	TME_BIT(2)
63 #define TME_BT458_COMMAND_ENABLE_DISPLAY_OL1	TME_BIT(1)
64 #define TME_BT458_COMMAND_ENABLE_DISPLAY_OL0	TME_BIT(0)
65 
66 /* the bt458 state: */
67 struct tme_bt458 {
68 
69   /* the bt458 address register: */
70   tme_uint8_t tme_bt458_address;
71 
72   /* the bt458 rgb address register: */
73   tme_uint8_t tme_bt458_rgb;
74 
75   /* the bt458 registers: */
76   tme_uint8_t tme_bt458_regs[TME_BT458_REG_CONTROL_LAST + 1 - TME_BT458_REG_CONTROL_FIRST];
77 
78   /* the bt458 colormap: */
79   tme_uint8_t *tme_bt458_cmap_primaries[3];
80 #define tme_bt458_cmap_r tme_bt458_cmap_primaries[0]
81 #define tme_bt458_cmap_g tme_bt458_cmap_primaries[1]
82 #define tme_bt458_cmap_b tme_bt458_cmap_primaries[2]
83 
84   /* the bt458 overlay map: */
85   tme_uint8_t tme_bt458_omap_primaries[3][4];
86 #define tme_bt458_omap_r tme_bt458_omap_primaries[0]
87 #define tme_bt458_omap_g tme_bt458_omap_primaries[1]
88 #define tme_bt458_omap_b tme_bt458_omap_primaries[2]
89 
90   /* the closest regular colormap indices for the overlay map: */
91   tme_uint8_t tme_bt458_omap_cmap_indices[4];
92 };
93 
94 /* prototypes: */
95 
96 /* this updates the best regular colormap indices for the colors in
97    the overlay map.  it returns nonzero if any of them changed: */
98 int tme_bt458_omap_best _TME_P((struct tme_bt458 *));
99 
100 #endif /* !_TME_IC_BT458_H */
101