aboutsummaryrefslogtreecommitdiffstats
path: root/include/radio.h
blob: 209a1ef6f6c675a222b8ea0f56ca40eb91d7dff3 (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
/**
 * This file is part of libsamsung-ipc.
 *
 * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com>
 *
 * libsamsung-ipc is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * libsamsung-ipc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with libsamsung-ipc.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef __RADIO_H__
#define __RADIO_H__

#include "types.h"
#include "util.h"

#define IPC_CLIENT_TYPE_CRESPO      1
#define IPC_CLIENT_TYPE_H1          2

#define IPC_COMMAND(f)	((f->group << 8) | f->index)
#define IPC_GROUP(m)	(m >> 8)
#define IPC_INDEX(m)	(m & 0xff)

/* IPC header for use by device specific code*/
struct ipc_header {
	unsigned short length;
	unsigned char mseq, aseq;
	unsigned char group, index, type;
} __attribute__((__packed__));

/* Request struct passed as parameter to ipc_send() */
struct ipc_request {
	unsigned char mseq, aseq, group, index, type;
	unsigned int length;
	unsigned char *data;
};

/* Response struct returned by ipc_recv() */
struct ipc_response {
	unsigned char mseq, aseq;
	unsigned short command;
	unsigned char type;
	unsigned int data_length;
	unsigned char *data;
};

int ipc_init(int client_type);
int ipc_boostrap(void);
int ipc_open(void);
int ipc_close(void);
int ipc_fd_get(void);

void ipc_power_on(void);
void ipc_power_off(void);

void ipc_send(struct ipc_request *request);
int ipc_recv(struct ipc_response *response);

/* Convenience functions for ipc_send */
void ipc_msg_send(const int command, const int type, unsigned char *data, const int length, unsigned char mseq);
void ipc_msg_send_get(const int command, unsigned char aseq);
void ipc_msg_send_exec(const int command, unsigned char aseq);

/* Utility functions */
const char *ipc_str(struct ipc_response *frame);
const char *ipc_response_type(struct ipc_response *frame);

#endif