summaryrefslogtreecommitdiff
path: root/hw/common.h
blob: 76c88f47375971de188053426c4eab9241e63c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * libdevice-node
 *
 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef __HW_COMMON_H__
#define __HW_COMMON_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

#define MAKE_TAG_CONSTANT(A,B,C,D)	(((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
#define HARDWARE_INFO_TAG	MAKE_TAG_CONSTANT('T','H','I','T')

struct hw_common;
struct hw_info {
	/* magic must be initialized to HARDWARE_INFO_TAG */
	uint32_t magic;
	/* HAL version */
	uint16_t hal_version;
	/* device version */
	uint16_t device_version;
	/* device id */
	const char *id;
	/* device name */
	const char *name;
	/* author name */
	const char *author;
	/* module's dso */
	void *dso;
	/* reserved for future use */
	uint32_t reserved[8];
	/* open device */
	int (*open)(struct hw_info *info,
			const char *id, struct hw_common **common);
	/* close device */
	int (*close)(struct hw_common *common);
};

struct hw_common {
	/* indicate to this device information structure */
	struct hw_info *info;
};

#define MAKE_VERSION(maj,min) \
	((((maj) & 0xff) << 8) | ((min) & 0xff))

/**
 * Version of the struct hw_info
 */
#define HARDWARE_INFO_VERSION	MAKE_VERSION(1,0)

/**
 * Name of the hardware info symbolic (Tizen Hardware Info)
 */
#define HARDWARE_INFO_SYM		TizenHwInfo

int hw_get_info(const char *id, const struct hw_info **info);

/**
 * Structure define of hardware info module
 * All hardware module should be use below define
 * to make a specific structure for Tizen HAL.
 * hw_get_info function will load a hw_info structure
 * by using TizenHwInfo name at runtime.
 * TizenHwInfo means Tizen Hardware Info.
 */
#define HARDWARE_MODULE_STRUCTURE	\
	__attribute__ ((visibility("default"))) \
	struct hw_info HARDWARE_INFO_SYM

#ifdef __cplusplus
}
#endif

#endif