Home | History | Annotate | Download | only in hardware
      1 /*
      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 
     29 typedef struct consumerir_freq_range {
     30     int min;
     31     int max;
     32 } consumerir_freq_range_t;
     33 
     34 typedef struct consumerir_module {
     35     /**
     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      */
     41     struct hw_module_t common;
     42 } consumerir_module_t;
     43 
     44 typedef struct consumerir_device {
     45     /**
     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      */
     51     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,
     66             const int pattern[], int pattern_len);
     67 
     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
     81      * appropriate values for the transmitter, up to len elements.
     82      *
     83      * returns: the number of ranges on success. A negative error code on error.
     84      */
     85     int (*get_carrier_freqs)(struct consumerir_device *dev,
     86             size_t len, consumerir_freq_range_t *ranges);
     87 
     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 */
     93