Device: Various improvements: added missing functions, mutex, threaded recv loop
[hayes-ril.git] / hayes-ril.h
index 55120cb..1966ff6 100644 (file)
@@ -3,10 +3,6 @@
  *
  * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
  * 
- * Based on htcgeneric-ril, reference-ril:
- * Copyright 2006-2011, htcgeneric-ril contributors
- * Copyright 2006, The Android Open Source Project
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,6 +19,9 @@
 #ifndef _HAYES_RIL_H_
 #define _HAYES_RIL_H_
 
+#define RIL_DEVICE_LOCK(ril_device_p) pthread_mutex_lock(&(ril_device_p->handlers->transport->mutex));
+#define RIL_DEVICE_UNLOCK(ril_device_p) pthread_mutex_unlock(&(ril_device_p->handlers->transport->mutex));
+
 #define DEV_GSM                RIL_DEVICE_TYPE_GSM
 #define DEV_CDMA       RIL_DEVICE_TYPE_CDMA
 
@@ -58,7 +57,10 @@ struct ril_device_transport_handlers {
        int (*send)(void *sdata, void **data, int length);
        int (*recv)(void *sdata, void **data, int length);
 
-       int (*poll)(void *sdata);
+       int (*recv_poll)(void *sdata);
+
+       pthread_t recv_thread;
+       pthread_mutex_t mutex;
 };
 
 struct ril_device_handlers {
@@ -76,11 +78,20 @@ struct ril_device {
 
 // Device
 void ril_device_register(struct ril_device **ril_device_p);
+int ril_device_init(struct ril_device *ril_device_p);
+int ril_device_deinit(struct ril_device *ril_device_p);
+
 int ril_device_data_create(struct ril_device *ril_device_p);
+int ril_device_data_destroy(struct ril_device *ril_device_p);
+int ril_device_boot(struct ril_device *ril_device_p);
 int ril_device_boot(struct ril_device *ril_device_p);
 int ril_device_power_on(struct ril_device *ril_device_p);
 int ril_device_power_off(struct ril_device *ril_device_p);
 int ril_device_open(struct ril_device *ril_device_p);
+int ril_device_close(struct ril_device *ril_device_p);
 int ril_device_send(struct ril_device *ril_device_p, void *data, int length);
 int ril_device_recv(struct ril_device *ril_device_p, void **data, int length);
+int ril_device_recv_poll(struct ril_device *ril_device_p);
+int ril_device_recv_thread_start(struct ril_device *ril_device_p);
+
 #endif