Described restrictions for common HAL object methods.
Inheritance of HAL object is performed by composing a child structure of a single parent structure located at offset 0 followed by new data members and function pointers in the child structure. For example, struct child { struct parent common; int a_data_member; void (*a_method)(struct child *c, int v); }; HAL code assumes this layout when accessing child structures given a pointer to a parent structure such that users write code like the following... void child_method(struct *parent, int v) { struct child * c = (struct child*)parent; // do stuff with c } Code above will break if a member is added before "common" in "struct child". This change adds comments that describe the restriction on the location of parent HAL objects within a derived HAL object. HAL objects that already have comments that describe the required location of parent objects are not modified. Change-Id: Ibe4300275286ef275b2097534c84f1029d761d87
This commit is contained in:
parent
4c847f2b79
commit
84d35492b1
14 changed files with 140 additions and 2 deletions
|
@ -103,6 +103,12 @@ typedef struct activity_event {
|
||||||
} activity_event_t;
|
} activity_event_t;
|
||||||
|
|
||||||
typedef struct activity_recognition_module {
|
typedef struct activity_recognition_module {
|
||||||
|
/**
|
||||||
|
* Common methods of the activity recognition module. This *must* be the first member of
|
||||||
|
* activity_recognition_module as users of this structure will cast a hw_module_t to
|
||||||
|
* activity_recognition_module pointer in contexts where it's known the hw_module_t
|
||||||
|
* references an activity_recognition_module.
|
||||||
|
*/
|
||||||
hw_module_t common;
|
hw_module_t common;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -126,6 +132,12 @@ typedef struct activity_recognition_callback_procs {
|
||||||
} activity_recognition_callback_procs_t;
|
} activity_recognition_callback_procs_t;
|
||||||
|
|
||||||
typedef struct activity_recognition_device {
|
typedef struct activity_recognition_device {
|
||||||
|
/**
|
||||||
|
* Common methods of the activity recognition device. This *must* be the first member of
|
||||||
|
* activity_recognition_device as users of this structure will cast a hw_device_t to
|
||||||
|
* activity_recognition_device pointer in contexts where it's known the hw_device_t
|
||||||
|
* references an activity_recognition_device.
|
||||||
|
*/
|
||||||
hw_device_t common;
|
hw_device_t common;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -260,6 +260,11 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct audio_stream_out {
|
struct audio_stream_out {
|
||||||
|
/**
|
||||||
|
* Common methods of the audio stream out. This *must* be the first member of audio_stream_out
|
||||||
|
* as users of this structure will cast a audio_stream to audio_stream_out pointer in contexts
|
||||||
|
* where it's known the audio_stream references an audio_stream_out.
|
||||||
|
*/
|
||||||
struct audio_stream common;
|
struct audio_stream common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -383,6 +388,11 @@ struct audio_stream_out {
|
||||||
typedef struct audio_stream_out audio_stream_out_t;
|
typedef struct audio_stream_out audio_stream_out_t;
|
||||||
|
|
||||||
struct audio_stream_in {
|
struct audio_stream_in {
|
||||||
|
/**
|
||||||
|
* Common methods of the audio stream in. This *must* be the first member of audio_stream_in
|
||||||
|
* as users of this structure will cast a audio_stream to audio_stream_in pointer in contexts
|
||||||
|
* where it's known the audio_stream references an audio_stream_in.
|
||||||
|
*/
|
||||||
struct audio_stream common;
|
struct audio_stream common;
|
||||||
|
|
||||||
/** set the input gain for the audio driver. This method is for
|
/** set the input gain for the audio driver. This method is for
|
||||||
|
@ -439,6 +449,11 @@ struct audio_module {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct audio_hw_device {
|
struct audio_hw_device {
|
||||||
|
/**
|
||||||
|
* Common methods of the audio device. This *must* be the first member of audio_hw_device
|
||||||
|
* as users of this structure will cast a hw_device_t to audio_hw_device pointer in contexts
|
||||||
|
* where it's known the hw_device_t references an audio_hw_device.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -423,6 +423,12 @@ typedef struct audio_policy_module {
|
||||||
} audio_policy_module_t;
|
} audio_policy_module_t;
|
||||||
|
|
||||||
struct audio_policy_device {
|
struct audio_policy_device {
|
||||||
|
/**
|
||||||
|
* Common methods of the audio policy device. This *must* be the first member of
|
||||||
|
* audio_policy_device as users of this structure will cast a hw_device_t to
|
||||||
|
* audio_policy_device pointer in contexts where it's known the hw_device_t references an
|
||||||
|
* audio_policy_device.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
int (*create_audio_policy)(const struct audio_policy_device *device,
|
int (*create_audio_policy)(const struct audio_policy_device *device,
|
||||||
|
|
|
@ -254,6 +254,12 @@ typedef struct camera_module_callbacks {
|
||||||
} camera_module_callbacks_t;
|
} camera_module_callbacks_t;
|
||||||
|
|
||||||
typedef struct camera_module {
|
typedef struct camera_module {
|
||||||
|
/**
|
||||||
|
* Common methods of the camera module. This *must* be the first member of
|
||||||
|
* camera_module as users of this structure will cast a hw_module_t to
|
||||||
|
* camera_module pointer in contexts where it's known the hw_module_t references a
|
||||||
|
* camera_module.
|
||||||
|
*/
|
||||||
hw_module_t common;
|
hw_module_t common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,10 +32,22 @@ typedef struct consumerir_freq_range {
|
||||||
} consumerir_freq_range_t;
|
} consumerir_freq_range_t;
|
||||||
|
|
||||||
typedef struct consumerir_module {
|
typedef struct consumerir_module {
|
||||||
|
/**
|
||||||
|
* Common methods of the consumer IR module. This *must* be the first member of
|
||||||
|
* consumerir_module as users of this structure will cast a hw_module_t to
|
||||||
|
* consumerir_module pointer in contexts where it's known the hw_module_t references a
|
||||||
|
* consumerir_module.
|
||||||
|
*/
|
||||||
struct hw_module_t common;
|
struct hw_module_t common;
|
||||||
} consumerir_module_t;
|
} consumerir_module_t;
|
||||||
|
|
||||||
typedef struct consumerir_device {
|
typedef struct consumerir_device {
|
||||||
|
/**
|
||||||
|
* Common methods of the consumer IR device. This *must* be the first member of
|
||||||
|
* consumerir_device as users of this structure will cast a hw_device_t to
|
||||||
|
* consumerir_device pointer in contexts where it's known the hw_device_t references a
|
||||||
|
* consumerir_device.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -36,6 +36,12 @@ __BEGIN_DECLS
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct framebuffer_device_t {
|
typedef struct framebuffer_device_t {
|
||||||
|
/**
|
||||||
|
* Common methods of the framebuffer device. This *must* be the first member of
|
||||||
|
* framebuffer_device_t as users of this structure will cast a hw_device_t to
|
||||||
|
* framebuffer_device_t pointer in contexts where it's known the hw_device_t references a
|
||||||
|
* framebuffer_device_t.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/* flags describing some attributes of the framebuffer */
|
/* flags describing some attributes of the framebuffer */
|
||||||
|
|
|
@ -69,6 +69,12 @@ typedef void (*fingerprint_notify_t)(fingerprint_msg_t msg);
|
||||||
|
|
||||||
/* Synchronous operation */
|
/* Synchronous operation */
|
||||||
typedef struct fingerprint_device {
|
typedef struct fingerprint_device {
|
||||||
|
/**
|
||||||
|
* Common methods of the fingerprint device. This *must* be the first member of
|
||||||
|
* fingerprint_device as users of this structure will cast a hw_device_t to
|
||||||
|
* fingerprint_device pointer in contexts where it's known the hw_device_t references a
|
||||||
|
* fingerprint_device.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -121,6 +127,12 @@ typedef struct fingerprint_device {
|
||||||
} fingerprint_device_t;
|
} fingerprint_device_t;
|
||||||
|
|
||||||
typedef struct fingerprint_module {
|
typedef struct fingerprint_module {
|
||||||
|
/**
|
||||||
|
* Common methods of the fingerprint module. This *must* be the first member of
|
||||||
|
* fingerprint_module as users of this structure will cast a hw_module_t to
|
||||||
|
* fingerprint_module pointer in contexts where it's known the hw_module_t references a
|
||||||
|
* fingerprint_module.
|
||||||
|
*/
|
||||||
struct hw_module_t common;
|
struct hw_module_t common;
|
||||||
} fingerprint_module_t;
|
} fingerprint_module_t;
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,11 @@ typedef struct hdmi_event {
|
||||||
typedef void (*event_callback_t)(const hdmi_event_t* event, void* arg);
|
typedef void (*event_callback_t)(const hdmi_event_t* event, void* arg);
|
||||||
|
|
||||||
typedef struct hdmi_cec_module {
|
typedef struct hdmi_cec_module {
|
||||||
|
/**
|
||||||
|
* Common methods of the HDMI CEC module. This *must* be the first member of
|
||||||
|
* hdmi_cec_module as users of this structure will cast a hw_module_t to hdmi_cec_module
|
||||||
|
* pointer in contexts where it's known the hw_module_t references a hdmi_cec_module.
|
||||||
|
*/
|
||||||
struct hw_module_t common;
|
struct hw_module_t common;
|
||||||
} hdmi_module_t;
|
} hdmi_module_t;
|
||||||
|
|
||||||
|
@ -218,6 +223,11 @@ typedef struct hdmi_cec_module {
|
||||||
* HDMI-CEC HAL interface definition.
|
* HDMI-CEC HAL interface definition.
|
||||||
*/
|
*/
|
||||||
typedef struct hdmi_cec_device {
|
typedef struct hdmi_cec_device {
|
||||||
|
/**
|
||||||
|
* Common methods of the HDMI CEC device. This *must* be the first member of
|
||||||
|
* hdmi_cec_device as users of this structure will cast a hw_device_t to hdmi_cec_device
|
||||||
|
* pointer in contexts where it's known the hw_device_t references a hdmi_cec_device.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -471,10 +471,22 @@ typedef struct hwc_procs {
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct hwc_module {
|
typedef struct hwc_module {
|
||||||
|
/**
|
||||||
|
* Common methods of the hardware composer module. This *must* be the first member of
|
||||||
|
* hwc_module as users of this structure will cast a hw_module_t to
|
||||||
|
* hwc_module pointer in contexts where it's known the hw_module_t references a
|
||||||
|
* hwc_module.
|
||||||
|
*/
|
||||||
struct hw_module_t common;
|
struct hw_module_t common;
|
||||||
} hwc_module_t;
|
} hwc_module_t;
|
||||||
|
|
||||||
typedef struct hwc_composer_device_1 {
|
typedef struct hwc_composer_device_1 {
|
||||||
|
/**
|
||||||
|
* Common methods of the hardware composer device. This *must* be the first member of
|
||||||
|
* hwc_composer_device_1 as users of this structure will cast a hw_device_t to
|
||||||
|
* hwc_composer_device_1 pointer in contexts where it's known the hw_device_t references a
|
||||||
|
* hwc_composer_device_1.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -83,6 +83,12 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct keystore_module {
|
struct keystore_module {
|
||||||
|
/**
|
||||||
|
* Common methods of the keystore module. This *must* be the first member of
|
||||||
|
* keystore_module as users of this structure will cast a hw_module_t to
|
||||||
|
* keystore_module pointer in contexts where it's known the hw_module_t references a
|
||||||
|
* keystore_module.
|
||||||
|
*/
|
||||||
hw_module_t common;
|
hw_module_t common;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -166,6 +172,12 @@ typedef struct {
|
||||||
* The parameters that can be set for a given keymaster implementation.
|
* The parameters that can be set for a given keymaster implementation.
|
||||||
*/
|
*/
|
||||||
struct keymaster_device {
|
struct keymaster_device {
|
||||||
|
/**
|
||||||
|
* Common methods of the keymaster device. This *must* be the first member of
|
||||||
|
* keymaster_device as users of this structure will cast a hw_device_t to
|
||||||
|
* keymaster_device pointer in contexts where it's known the hw_device_t references a
|
||||||
|
* keymaster_device.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -282,4 +294,3 @@ static inline int keymaster_close(keymaster_device_t* device)
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#endif // ANDROID_HARDWARE_KEYMASTER_H
|
#endif // ANDROID_HARDWARE_KEYMASTER_H
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,12 @@ struct local_time_module {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct local_time_hw_device {
|
struct local_time_hw_device {
|
||||||
|
/**
|
||||||
|
* Common methods of the local time hardware device. This *must* be the first member of
|
||||||
|
* local_time_hw_device as users of this structure will cast a hw_device_t to
|
||||||
|
* local_time_hw_device pointer in contexts where it's known the hw_device_t references a
|
||||||
|
* local_time_hw_device.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -210,6 +210,12 @@ static inline int nfc_nci_close(nfc_nci_device_t* dev) {
|
||||||
#define NFC_PN544_CONTROLLER "pn544"
|
#define NFC_PN544_CONTROLLER "pn544"
|
||||||
|
|
||||||
typedef struct nfc_module_t {
|
typedef struct nfc_module_t {
|
||||||
|
/**
|
||||||
|
* Common methods of the NFC NXP PN544 module. This *must* be the first member of
|
||||||
|
* nfc_module_t as users of this structure will cast a hw_module_t to
|
||||||
|
* nfc_module_t pointer in contexts where it's known the hw_module_t references an
|
||||||
|
* nfc_module_t.
|
||||||
|
*/
|
||||||
struct hw_module_t common;
|
struct hw_module_t common;
|
||||||
} nfc_module_t;
|
} nfc_module_t;
|
||||||
|
|
||||||
|
@ -227,6 +233,12 @@ typedef enum {
|
||||||
} nfc_pn544_linktype;
|
} nfc_pn544_linktype;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
/**
|
||||||
|
* Common methods of the NFC NXP PN544 device. This *must* be the first member of
|
||||||
|
* nfc_pn544_device_t as users of this structure will cast a hw_device_t to
|
||||||
|
* nfc_pn544_device_t pointer in contexts where it's known the hw_device_t references an
|
||||||
|
* nfc_pn544_device_t.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/* The number of EEPROM registers to write */
|
/* The number of EEPROM registers to write */
|
||||||
|
|
|
@ -32,10 +32,22 @@ __BEGIN_DECLS
|
||||||
#define NFC_TAG_ID "tag"
|
#define NFC_TAG_ID "tag"
|
||||||
|
|
||||||
typedef struct nfc_tag_module_t {
|
typedef struct nfc_tag_module_t {
|
||||||
|
/**
|
||||||
|
* Common methods of the NFC tag module. This *must* be the first member of
|
||||||
|
* nfc_tag_module_t as users of this structure will cast a hw_module_t to
|
||||||
|
* nfc_tag_module_t pointer in contexts where it's known the hw_module_t references a
|
||||||
|
* nfc_tag_module_t.
|
||||||
|
*/
|
||||||
struct hw_module_t common;
|
struct hw_module_t common;
|
||||||
} nfc_tag_module_t;
|
} nfc_tag_module_t;
|
||||||
|
|
||||||
typedef struct nfc_tag_device {
|
typedef struct nfc_tag_device {
|
||||||
|
/**
|
||||||
|
* Common methods of the NFC tag device. This *must* be the first member of
|
||||||
|
* nfc_tag_device_t as users of this structure will cast a hw_device_t to
|
||||||
|
* nfc_tag_device_t pointer in contexts where it's known the hw_device_t references a
|
||||||
|
* nfc_tag_device_t.
|
||||||
|
*/
|
||||||
struct hw_device_t common;
|
struct hw_device_t common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,7 +35,13 @@ __BEGIN_DECLS
|
||||||
|
|
||||||
struct vibrator_device;
|
struct vibrator_device;
|
||||||
typedef struct vibrator_device {
|
typedef struct vibrator_device {
|
||||||
struct hw_device_t common;
|
/**
|
||||||
|
* Common methods of the vibrator device. This *must* be the first member of
|
||||||
|
* vibrator_device as users of this structure will cast a hw_device_t to
|
||||||
|
* vibrator_device pointer in contexts where it's known the hw_device_t references a
|
||||||
|
* vibrator_device.
|
||||||
|
*/
|
||||||
|
struct hw_device_t common;
|
||||||
|
|
||||||
/** Turn on vibrator
|
/** Turn on vibrator
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue