1 /*
2 Copyright (c) 2012, Broadcom Europe Ltd
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7     * Redistributions of source code must retain the above copyright
8       notice, this list of conditions and the following disclaimer.
9     * Redistributions in binary form must reproduce the above copyright
10       notice, this list of conditions and the following disclaimer in the
11       documentation and/or other materials provided with the distribution.
12     * Neither the name of the copyright holder nor the
13       names of its contributors may be used to endorse or promote products
14       derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 // Header file with useful bits from other headers
29 
30 #ifndef BCM_HOST_H
31 #define BCM_HOST_H
32 
33 #include <stdint.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 void bcm_host_init(void);
40 void bcm_host_deinit(void);
41 
42 int32_t graphics_get_display_size( const uint16_t display_number,
43                                                     uint32_t *width,
44                                                     uint32_t *height);
45 
46 unsigned bcm_host_get_peripheral_address(void);
47 unsigned bcm_host_get_peripheral_size(void);
48 unsigned bcm_host_get_sdram_address(void);
49 
50 #include "interface/vmcs_host/vc_dispmanx.h"
51 #include "interface/vmcs_host/vc_tvservice.h"
52 #include "interface/vmcs_host/vc_cec.h"
53 #include "interface/vmcs_host/vc_cecservice.h"
54 #include "interface/vmcs_host/vcgencmd.h"
55 
56 /* Returns the type of the Pi being used
57 */
58 #define BCM_HOST_BOARD_TYPE_MODELA 0
59 #define BCM_HOST_BOARD_TYPE_MODELB 1
60 #define BCM_HOST_BOARD_TYPE_MODELAPLUS 2
61 #define BCM_HOST_BOARD_TYPE_MODELBPLUS 3
62 #define BCM_HOST_BOARD_TYPE_PI2MODELB 4
63 #define BCM_HOST_BOARD_TYPE_ALPHA 5
64 #define BCM_HOST_BOARD_TYPE_CM 6
65 #define BCM_HOST_BOARD_TYPE_CM2 7
66 #define BCM_HOST_BOARD_TYPE_PI3MODELB 8
67 #define BCM_HOST_BOARD_TYPE_PI0 9
68 #define BCM_HOST_BOARD_TYPE_CM3 0xa
69 #define BCM_HOST_BOARD_TYPE_CUSTOM 0xb
70 #define BCM_HOST_BOARD_TYPE_PI0W 0xc
71 #define BCM_HOST_BOARD_TYPE_PI3MODELBPLUS 0xd
72 #define BCM_HOST_BOARD_TYPE_PI3MODELAPLUS 0xe
73 #define BCM_HOST_BOARD_TYPE_FPGA 0xf
74 #define BCM_HOST_BOARD_TYPE_CM3PLUS 0x10
75 #define BCM_HOST_BOARD_TYPE_PI4MODELB 0x11
76 
77 extern int bcm_host_get_model_type(void);
78 
79 /* Returns 1 if model is  Pi4
80 */
81 extern int bcm_host_is_model_pi4(void);
82 
83 /* Returns 1 if fkms is active (dtoverlay=v3d-fkms-vc4)
84 */
85 extern int bcm_host_is_fkms_active(void);
86 
87 /* Returns 1 if kms is active (dtoverlay=v3d-kms-vc4)
88 */
89 extern int bcm_host_is_kms_active(void);
90 
91 /* returns the processor ID
92 */
93 #define BCM_HOST_PROCESSOR_BCM2835 0
94 #define BCM_HOST_PROCESSOR_BCM2836 1
95 #define BCM_HOST_PROCESSOR_BCM2837 2
96 #define BCM_HOST_PROCESSOR_BCM2838 3
97 
98 extern int bcm_host_get_processor_id(void);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif
105 
106