1 #include <binder/Parcel.h>
3 #include "BpAndroidShm.h"
7 int BpAndroidShm::sendCommand(const char*command
) {
9 data
.writeInterfaceToken(
10 IAndroidShm::getInterfaceDescriptor());
11 data
.writeCString(command
);
12 status_t status
= remote()->transact(HW_SENDCOMMAND
, data
, &reply
);
13 if(status
!= NO_ERROR
) {
14 ALOGE("print sendCommand error: %s", strerror(-status
));
16 status
= reply
.readInt32();
21 sp
<IMemoryHeap
> BpAndroidShm::getBuffer(int index
) {
23 sp
<IMemoryHeap
> memHeap
= NULL
;
24 data
.writeInterfaceToken(IAndroidShm::getInterfaceDescriptor());
25 data
.writeInt32(index
);
26 remote()->transact(HW_GETBUFFER
, data
, &reply
);
27 memHeap
= interface_cast
<IMemoryHeap
> (reply
.readStrongBinder());
31 BpAndroidShm::BpAndroidShm( const sp
<IBinder
>& impl
)
32 : BpInterface
<IAndroidShm
>(impl
)
35 BpAndroidShm::~BpAndroidShm()
38 int BpAndroidShm::allocShm(const int size
) { // if negative return value is error
40 data
.writeInterfaceToken(IAndroidShm::getInterfaceDescriptor());
41 data
.writeInt32(size
);
42 status_t status
= remote()->transact(HW_ALLOC_SHM
, data
, &reply
);
43 if(status
!= NO_ERROR
) {
44 ALOGE("print allocShm error: %s", strerror(-status
));
46 status
= reply
.readInt32();
51 int BpAndroidShm::removeShm(const unsigned int index
) { // shared memory Á¦°Å
53 data
.writeInterfaceToken(IAndroidShm::getInterfaceDescriptor());
54 data
.writeInt32(index
);
55 status_t status
= remote()->transact(HW_REMOVE_SHM
, data
, &reply
);
56 if(status
!= NO_ERROR
) {
57 ALOGE("print removeShm error: %s", strerror(-status
));
59 status
= reply
.readInt32();
64 int BpAndroidShm::isAllocated(const unsigned int index
) { // allocated ¿©ºÎ È®ÀÎ
66 data
.writeInterfaceToken(IAndroidShm::getInterfaceDescriptor());
67 data
.writeInt32(index
);
68 status_t status
= remote()->transact(HW_IS_ALLOCATED
, data
, &reply
);
69 if(status
!= NO_ERROR
) {
70 ALOGE("print isAllocated error: %s", strerror(-status
));
72 status
= reply
.readInt32();
77 int BpAndroidShm::setRegistryIndex(const unsigned int index
) {
79 data
.writeInterfaceToken(IAndroidShm::getInterfaceDescriptor());
80 data
.writeInt32(index
);
81 status_t status
= remote()->transact(HW_SET_REGISTRY_INDEX
, data
, &reply
);
82 if(status
!= NO_ERROR
) {
83 ALOGE("print setRegistryIndex error: %s", strerror(-status
));
85 status
= reply
.readInt32();
90 int BpAndroidShm::getRegistryIndex() {
92 data
.writeInterfaceToken(IAndroidShm::getInterfaceDescriptor());
93 status_t status
= remote()->transact(HW_GET_REGISTRY_INDEX
, data
, &reply
);
94 if(status
!= NO_ERROR
) {
95 ALOGE("print getRegistryIndex error: %s", strerror(-status
));
97 status
= reply
.readInt32();
102 sp
<IMemoryHeap
> BpAndroidShm::InitSemaphore(const char* name
) {
104 sp
<IMemoryHeap
> memHeap
= NULL
;
105 data
.writeInterfaceToken(IAndroidShm::getInterfaceDescriptor());
106 data
.writeCString(name
);
107 status_t status
= remote()->transact(HW_INIT_SEMAPHORE
, data
, &reply
);
108 memHeap
= interface_cast
<IMemoryHeap
> (reply
.readStrongBinder());