blob: 15334c1111637a0b41975b6d7f7bdf52f0ce9784 [file] [log] [blame]
Alex Rayfe46e6a2013-09-04 23:32:14 -07001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H
18#define ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H
19
20#include <stdint.h>
21#include <sys/cdefs.h>
22#include <hardware/hardware.h>
23#include <hardware/hwcomposer_defs.h>
24
25#define CONSUMERIR_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
26#define CONSUMERIR_HARDWARE_MODULE_ID "consumerir"
27#define CONSUMERIR_TRANSMITTER "transmitter"
28
29typedef struct consumerir_freq_range {
30 int min;
31 int max;
32} consumerir_freq_range_t;
33
34typedef struct consumerir_module {
Stewart Miles84d35492014-05-01 09:03:27 -070035 /**
36 * Common methods of the consumer IR module. This *must* be the first member of
37 * consumerir_module as users of this structure will cast a hw_module_t to
38 * consumerir_module pointer in contexts where it's known the hw_module_t references a
39 * consumerir_module.
40 */
Alex Rayfe46e6a2013-09-04 23:32:14 -070041 struct hw_module_t common;
42} consumerir_module_t;
43
44typedef struct consumerir_device {
Stewart Miles84d35492014-05-01 09:03:27 -070045 /**
46 * Common methods of the consumer IR device. This *must* be the first member of
47 * consumerir_device as users of this structure will cast a hw_device_t to
48 * consumerir_device pointer in contexts where it's known the hw_device_t references a
49 * consumerir_device.
50 */
Alex Rayfe46e6a2013-09-04 23:32:14 -070051 struct hw_device_t common;
52
53 /*
54 * (*transmit)() is called to by the ConsumerIrService to send an IR pattern
55 * at a given carrier_freq.
56 *
57 * The pattern is alternating series of carrier on and off periods measured in
58 * microseconds. The carrier should be turned off at the end of a transmit
59 * even if there are and odd number of entries in the pattern array.
60 *
61 * This call should return when the transmit is complete or encounters an error.
62 *
63 * returns: 0 on success. A negative error code on error.
64 */
65 int (*transmit)(struct consumerir_device *dev, int carrier_freq,
Alex Ray6670e242013-09-11 13:36:58 -070066 const int pattern[], int pattern_len);
Alex Rayfe46e6a2013-09-04 23:32:14 -070067
68 /*
69 * (*get_num_carrier_freqs)() is called by the ConsumerIrService to get the
70 * number of carrier freqs to allocate space for, which is then filled by
71 * a subsequent call to (*get_carrier_freqs)().
72 *
73 * returns: the number of ranges on success. A negative error code on error.
74 */
75 int (*get_num_carrier_freqs)(struct consumerir_device *dev);
76
77 /*
78 * (*get_carrier_freqs)() is called by the ConsumerIrService to enumerate
79 * which frequencies the IR transmitter supports. The HAL implementation
80 * should fill an array of consumerir_freq_range structs with the
Alex Rayd9d105a2013-09-11 16:20:07 -070081 * appropriate values for the transmitter, up to len elements.
Alex Rayfe46e6a2013-09-04 23:32:14 -070082 *
83 * returns: the number of ranges on success. A negative error code on error.
84 */
85 int (*get_carrier_freqs)(struct consumerir_device *dev,
Alex Rayd9d105a2013-09-11 16:20:07 -070086 size_t len, consumerir_freq_range_t *ranges);
Alex Rayfe46e6a2013-09-04 23:32:14 -070087
88 /* Reserved for future use. Must be NULL. */
89 void* reserved[8 - 3];
90} consumerir_device_t;
91
92#endif /* ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H */