1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2010-2013 Bluecherry, LLC <https://www.bluecherrydvr.com>
4  *
5  * Original author:
6  * Ben Collins <bcollins@ubuntu.com>
7  *
8  * Additional work by:
9  * John Brooks <john.brooks@bluecherry.net>
10  */
11 
12 #ifndef __SOLO6X10_OFFSETS_H
13 #define __SOLO6X10_OFFSETS_H
14 
15 #define SOLO_DISP_EXT_ADDR			0x00000000
16 #define SOLO_DISP_EXT_SIZE			0x00480000
17 
18 #define SOLO_EOSD_EXT_ADDR \
19 	(SOLO_DISP_EXT_ADDR + SOLO_DISP_EXT_SIZE)
20 #define SOLO_EOSD_EXT_SIZE(__solo) \
21 	(__solo->type == SOLO_DEV_6010 ? 0x10000 : 0x20000)
22 #define SOLO_EOSD_EXT_SIZE_MAX			0x20000
23 #define SOLO_EOSD_EXT_AREA(__solo) \
24 	(SOLO_EOSD_EXT_SIZE(__solo) * 32)
25 #define SOLO_EOSD_EXT_ADDR_CHAN(__solo, ch) \
26 	(SOLO_EOSD_EXT_ADDR + SOLO_EOSD_EXT_SIZE(__solo) * (ch))
27 
28 #define SOLO_MOTION_EXT_ADDR(__solo) \
29 	(SOLO_EOSD_EXT_ADDR + SOLO_EOSD_EXT_AREA(__solo))
30 #define SOLO_MOTION_EXT_SIZE			0x00080000
31 
32 #define SOLO_G723_EXT_ADDR(__solo) \
33 	(SOLO_MOTION_EXT_ADDR(__solo) + SOLO_MOTION_EXT_SIZE)
34 #define SOLO_G723_EXT_SIZE			0x00010000
35 
36 #define SOLO_CAP_EXT_ADDR(__solo) \
37 	(SOLO_G723_EXT_ADDR(__solo) + SOLO_G723_EXT_SIZE)
38 
39 /* 18 is the maximum number of pages required for PAL@D1, the largest frame
40  * possible */
41 #define SOLO_CAP_PAGE_SIZE			(18 << 16)
42 
43 /* Always allow the encoder enough for 16 channels, even if we have less. The
44  * exception is if we have card with only 32Megs of memory. */
45 #define SOLO_CAP_EXT_SIZE(__solo) \
46 	((((__solo->sdram_size <= (32 << 20)) ? 4 : 16) + 1)	\
47 	 * SOLO_CAP_PAGE_SIZE)
48 
49 #define SOLO_EREF_EXT_ADDR(__solo) \
50 	(SOLO_CAP_EXT_ADDR(__solo) + SOLO_CAP_EXT_SIZE(__solo))
51 #define SOLO_EREF_EXT_SIZE			0x00140000
52 #define SOLO_EREF_EXT_AREA(__solo) \
53 	(SOLO_EREF_EXT_SIZE * __solo->nr_chans * 2)
54 
55 #define __SOLO_JPEG_MIN_SIZE(__solo)		(__solo->nr_chans * 0x00080000)
56 
57 #define SOLO_MP4E_EXT_ADDR(__solo) \
58 	(SOLO_EREF_EXT_ADDR(__solo) + SOLO_EREF_EXT_AREA(__solo))
59 #define SOLO_MP4E_EXT_SIZE(__solo) \
60 	max((__solo->nr_chans * 0x00080000),				\
61 	    min(((__solo->sdram_size - SOLO_MP4E_EXT_ADDR(__solo)) -	\
62 		 __SOLO_JPEG_MIN_SIZE(__solo)), 0x00ff0000))
63 
64 #define __SOLO_JPEG_MIN_SIZE(__solo)		(__solo->nr_chans * 0x00080000)
65 #define SOLO_JPEG_EXT_ADDR(__solo) \
66 		(SOLO_MP4E_EXT_ADDR(__solo) + SOLO_MP4E_EXT_SIZE(__solo))
67 #define SOLO_JPEG_EXT_SIZE(__solo) \
68 	max(__SOLO_JPEG_MIN_SIZE(__solo),				\
69 	    min((__solo->sdram_size - SOLO_JPEG_EXT_ADDR(__solo)), 0x00ff0000))
70 
71 #define SOLO_SDRAM_END(__solo) \
72 	(SOLO_JPEG_EXT_ADDR(__solo) + SOLO_JPEG_EXT_SIZE(__solo))
73 
74 #endif /* __SOLO6X10_OFFSETS_H */
75