• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/uqmi/uqmid/services.h

  1 /*
  2  * uqmi -- tiny QMI support implementation
  3  *
  4  * Copyright (C) 2023 Alexander Couzens <lynxis@fe80.eu>
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the
 18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 19  * Boston, MA 02110-1301 USA.
 20  */
 21 
 22 #ifndef __UQMID_QMI_DEV_H
 23 #define __UQMID_QMI_DEV_H
 24 
 25 #include <stdint.h>
 26 #include <libubox/list.h>
 27 
 28 #include "uqmid.h"
 29 
 30 struct qmi_dev;
 31 struct qmi_request;
 32 
 33 enum {
 34         SERVICE_IDLE,
 35         SERVICE_WAIT_CID,
 36         SERVICE_READY,
 37 };
 38 
 39 struct qmi_service {
 40         int service; /*! service id */
 41         uint16_t client_id; /*! client id, unique per service */
 42         uint16_t tid; /*! the current transaction id */
 43 
 44         uint16_t major;
 45         uint16_t minor;
 46 
 47         int state;
 48 
 49         struct qmi_dev *qmi;
 50         struct list_head list; /*! entry on qmi_dev */
 51 
 52         /* contains all pending requests */
 53         struct list_head reqs;
 54 
 55         /* contains indication registers
 56          * a sorted llist by qmi msg id
 57          */
 58         struct list_head indications;
 59 };
 60 
 61 typedef void (*indication_cb)(struct qmi_service *service, struct qmi_msg *msg, void *data);
 62 struct qmi_indication {
 63         /* a sorted linked list by qmi_ind in indications */
 64         struct list_head list;
 65         /* qmi_ind the qmi message id.
 66          * Multiple callbacks can receive the same indication
 67          */
 68         uint16_t qmi_ind;
 69         indication_cb cb;
 70         void *cb_data;
 71 };
 72 
 73 struct qmi_service *uqmi_service_find(struct qmi_dev *qmi, int service_id);
 74 struct qmi_service *uqmi_service_find_or_init(struct qmi_dev *qmi, int service_id);
 75 int uqmi_service_open(struct qmi_dev *qmi);
 76 void uqmi_service_close(struct qmi_service *service);
 77 int uqmi_service_send_msg(struct qmi_service *service, struct qmi_request *req);
 78 int uqmi_service_send_msg2(struct qmi_dev *qmi, struct qmi_request *req, int service_id);
 79 int uqmi_service_send_simple(struct qmi_service *service,
 80                          int(*encode)(struct qmi_msg *msg),
 81                          request_cb cb, void *cb_data);
 82 
 83 int uqmi_service_get_next_tid(struct qmi_service *service);
 84 struct qmi_service *uqmi_service_create(struct qmi_dev *qmi, int service_id);
 85 
 86 /* callback for the ctrl when allocating the client id */
 87 void uqmi_service_get_client_id_cb(struct qmi_service *service, uint16_t client_id);
 88 void uqmi_service_close_cb(struct qmi_service *service);
 89 
 90 /* indications */
 91 
 92 int uqmi_service_register_indication(struct qmi_service *service, uint16_t indication, indication_cb cb, void *cb_data);
 93 int uqmi_service_remove_indication(struct qmi_service *service, uint16_t indication, indication_cb cb, void *cb_data);
 94 int uqmi_service_handle_indication(struct qmi_service *service, struct qmi_msg *msg);
 95 
 96 #endif /* __UQMID_QMI_DEV_H */
 97 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt