Skip to content

Commit

Permalink
libhardware: Add QCOM_HARDWARE ifdefs
Browse files Browse the repository at this point in the history
Change-Id: I8a903caad9716d5c9571fe4735567ae33a48aefd
  • Loading branch information
hyperb1iss committed Jul 26, 2013
1 parent 34f1908 commit 14f2bfb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
17 changes: 17 additions & 0 deletions include/hardware/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@ struct audio_config {

typedef struct audio_config audio_config_t;

#ifdef QCOM_HARDWARE
/** Structure to save buffer information for applying effects for
* LPA buffers */
struct buf_info {
int bufsize;
int nBufs;
int **buffers;
};
#endif

/* common audio stream parameters and operations */
struct audio_stream {
Expand Down Expand Up @@ -294,6 +296,7 @@ struct audio_stream_out {
uint32_t *dsp_frames);

#ifndef ICS_AUDIO_BLOB
#ifdef QCOM_HARDWARE
/**
* start audio data rendering
*/
Expand All @@ -313,6 +316,7 @@ struct audio_stream_out {
* stop audio data rendering
*/
int (*stop)(struct audio_stream_out *stream);
#endif

/**
* get the local time at which the next write to the audio driver will be presented.
Expand All @@ -321,6 +325,7 @@ struct audio_stream_out {
int (*get_next_write_timestamp)(const struct audio_stream_out *stream,
int64_t *timestamp);

#ifdef QCOM_HARDWARE
/**
* return the current timestamp after quering to the driver
*/
Expand All @@ -344,6 +349,7 @@ struct audio_stream_out {
int (*is_buffer_available) (const struct audio_stream_out *stream,
int *isAvail);
#endif
#endif

};
typedef struct audio_stream_out audio_stream_out_t;
Expand Down Expand Up @@ -421,6 +427,7 @@ typedef struct audio_stream_in audio_stream_in_t;
static inline size_t audio_stream_frame_size(const struct audio_stream *s)
{
size_t chan_samp_sz;
#ifdef QCOM_HARDWARE
uint32_t chan_mask = s->get_channels(s);
int format = s->get_format(s);
char *tmpparam;
Expand Down Expand Up @@ -458,6 +465,9 @@ static inline size_t audio_stream_frame_size(const struct audio_stream *s)
case AUDIO_FORMAT_AMR_WB:
chan_samp_sz = 61;
break;
#else
switch (s->get_format(s)) {
#endif
case AUDIO_FORMAT_PCM_16_BIT:
chan_samp_sz = sizeof(int16_t);
break;
Expand All @@ -467,7 +477,11 @@ static inline size_t audio_stream_frame_size(const struct audio_stream *s)
break;
}

#ifdef QCOM_HARDWARE
return popcount(chan_mask) * chan_samp_sz;
#else
return popcount(s->get_channels(s)) * chan_samp_sz;
#endif
}


Expand Down Expand Up @@ -638,6 +652,7 @@ struct audio_hw_device {
* method may leave it set to NULL.
*/
int (*get_master_mute)(struct audio_hw_device *dev, bool *mute);
#endif

#ifdef QCOM_LISTEN_FEATURE_ENABLE
/** This method opens the listen session and returns a handle */
Expand Down Expand Up @@ -669,6 +684,7 @@ static inline int audio_hw_device_close(struct audio_hw_device* device)
return device->common.close(&device->common);
}

#ifdef QCOM_HARDWARE
#ifdef __cplusplus
/**
*Observer class to post the Events from HAL to Flinger
Expand All @@ -679,6 +695,7 @@ class AudioEventObserver {
virtual void postEOS(int64_t delayUs) = 0;
};
#endif
#endif
__END_DECLS

#endif // ANDROID_AUDIO_INTERFACE_H
4 changes: 4 additions & 0 deletions include/hardware/gralloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ enum {
#endif
};

#ifdef QCOM_HARDWARE
enum {
/* Gralloc perform enums */
GRALLOC_MODULE_PERFORM_UPDATE_BUFFER_GEOMETRY = 0,
GRALLOC_MODULE_PERFORM_PRIVATE_START
};
#endif

/*****************************************************************************/

Expand Down Expand Up @@ -275,6 +277,7 @@ typedef struct gralloc_module_t {
typedef struct alloc_device_t {
struct hw_device_t common;

#ifdef QCOM_HARDWARE
/*
* (*allocSize)() Allocates a buffer in graphic memory with the requested
* bufferSize parameter and returns a buffer_handle_t and the stride in
Expand All @@ -287,6 +290,7 @@ typedef struct alloc_device_t {
int (*allocSize)(struct alloc_device_t* dev,
int w, int h, int format, int usage,
buffer_handle_t* handle, int* stride, int bufferSize);
#endif

/*
* (*alloc)() Allocates a buffer in graphic memory with the requested
Expand Down
6 changes: 6 additions & 0 deletions include/hardware/hwcomposer_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ enum {
* by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY).
*/
HWC_SKIP_LAYER = 0x00000001,
#ifdef QCOM_HARDWARE
HWC_SCREENSHOT_ANIMATOR_LAYER = 0x00000002,
#endif
};

/*
Expand Down Expand Up @@ -181,14 +183,18 @@ enum {
/* Allowed events for hwc_methods::eventControl() */
enum {
HWC_EVENT_VSYNC = 0,
#ifdef QCOM_HARDWARE
HWC_EVENT_ORIENTATION
#endif
};

/* Display types and associated mask bits. */
enum {
HWC_DISPLAY_PRIMARY = 0,
HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc.
#ifdef QCOM_HARDWARE
HWC_DISPLAY_VIRTUAL = 2, // WFD etc.
#endif
HWC_NUM_DISPLAY_TYPES
};

Expand Down
1 change: 0 additions & 1 deletion modules/audio/audio_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ static int adev_open(const hw_module_t* module, const char* name,
#ifndef ICS_AUDIO_BLOB
adev->device.get_master_volume = adev_get_master_volume;
adev->device.set_master_mute = adev_set_master_mute;
adev->device.get_master_mute = adev_get_master_mute;
#endif
adev->device.set_mode = adev_set_mode;
adev->device.set_mic_mute = adev_set_mic_mute;
Expand Down
14 changes: 12 additions & 2 deletions modules/usbaudio/audio_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ static int start_output_stream(struct stream_out *out)
return -EINVAL;

ALOGD("start_output_stream()");
#ifdef QCOM_HARDWARE
out->pcm = pcm_open(adev->card, adev->device, PCM_OUT | PCM_MMAP | PCM_NOIRQ , &pcm_config);

#else
out->pcm = pcm_open(adev->card, adev->device, PCM_OUT, &pcm_config);
#endif
if (out->pcm && !pcm_is_ready(out->pcm)) {
ALOGE("pcm_open() failed: %s", pcm_get_error(out->pcm));
pcm_close(out->pcm);
Expand Down Expand Up @@ -207,12 +210,19 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
out->standby = false;
}

#ifdef QCOM_HARDWARE
ret = pcm_mmap_write(out->pcm, (void *)buffer, bytes);

#else
pcm_write(out->pcm, (void *)buffer, bytes);
#endif
pthread_mutex_unlock(&out->lock);
pthread_mutex_unlock(&out->dev->lock);

#ifdef QCOM_HARDWARE
return ret? ret: bytes;
#else
return bytes;
#endif

err:
ALOGE("out_write() ERR");
Expand Down

0 comments on commit 14f2bfb

Please sign in to comment.