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