struct bcm2835_audio_instance {
struct device *dev;
- struct vchi_service *service;
+ unsigned service_handle;
struct completion msg_avail_comp;
struct mutex vchi_mutex;
struct bcm2835_alsa_stream *alsa_stream;
static void bcm2835_audio_lock(struct bcm2835_audio_instance *instance)
{
mutex_lock(&instance->vchi_mutex);
- vchi_service_use(instance->service);
+ vchi_service_use(instance->service_handle);
}
static void bcm2835_audio_unlock(struct bcm2835_audio_instance *instance)
{
- vchi_service_release(instance->service);
+ vchi_service_release(instance->service_handle);
mutex_unlock(&instance->vchi_mutex);
}
init_completion(&instance->msg_avail_comp);
}
- status = vchi_queue_kernel_message(instance->service,
+ status = vchi_queue_kernel_message(instance->service_handle,
m, sizeof(*m));
if (status) {
dev_err(instance->dev,
/* Open the VCHI service connections */
status = vchi_service_open(vchiq_instance, ¶ms,
- &instance->service);
+ &instance->service_handle);
if (status) {
dev_err(instance->dev,
}
/* Finished with the service for now */
- vchi_service_release(instance->service);
+ vchi_service_release(instance->service_handle);
return 0;
}
int status;
mutex_lock(&instance->vchi_mutex);
- vchi_service_use(instance->service);
+ vchi_service_use(instance->service_handle);
/* Close all VCHI service connections */
- status = vchi_service_close(instance->service);
+ status = vchi_service_close(instance->service_handle);
if (status) {
dev_err(instance->dev,
"failed to close VCHI service connection (status=%d)\n",
goto deinit;
bcm2835_audio_lock(instance);
- vchi_get_peer_version(instance->service, &instance->peer_version);
+ vchi_get_peer_version(instance->service_handle,
+ &instance->peer_version);
bcm2835_audio_unlock(instance);
if (instance->peer_version < 2 || force_bulk)
instance->max_packet = 0; /* bulk transfer */
count = size;
if (!instance->max_packet) {
/* Send the message to the videocore */
- status = vchi_bulk_queue_transmit(instance->service,
+ status = vchi_bulk_queue_transmit(instance->service_handle,
src, count,
VCHIQ_BULK_MODE_BLOCKING,
NULL);
while (count > 0) {
int bytes = min(instance->max_packet, count);
- status = vchi_queue_kernel_message(instance->service,
+ status = vchi_queue_kernel_message(instance->service_handle,
src, bytes);
src += bytes;
count -= bytes;
void *message;
};
-struct vchi_service {
- unsigned int handle;
-};
-
// Opaque handle for a VCHIQ instance
struct vchiq_instance;
* Global service API
*****************************************************************************/
// Routine to open a named service
-extern int32_t vchi_service_open(struct vchiq_instance *instance,
- struct vchiq_service_params *setup,
- struct vchi_service **service);
+extern int vchi_service_open(struct vchiq_instance *instance,
+ struct vchiq_service_params *params,
+ unsigned *handle);
-extern int32_t vchi_get_peer_version(struct vchi_service *service,
- short *peer_version);
+extern int32_t vchi_get_peer_version(unsigned handle, short *peer_version);
// Routine to close a named service
-extern int32_t vchi_service_close(struct vchi_service *service);
+extern int32_t vchi_service_close(unsigned handle);
// Routine to increment ref count on a named service
-extern int32_t vchi_service_use(struct vchi_service *service);
+extern int32_t vchi_service_use(unsigned handle);
// Routine to decrement ref count on a named service
-extern int32_t vchi_service_release(struct vchi_service *service);
+extern int32_t vchi_service_release(unsigned handle);
/* Routine to send a message from kernel memory across a service */
-extern int vchi_queue_kernel_message(struct vchi_service *service, void *data,
+extern int vchi_queue_kernel_message(unsigned handle, void *data,
unsigned int size);
// Routine to look at a message in place.
*****************************************************************************/
// Routine to prepare interface for a transfer from the other side
-extern int32_t vchi_bulk_queue_receive(struct vchi_service *service,
+extern int32_t vchi_bulk_queue_receive(unsigned handle,
void *data_dst,
uint32_t data_size,
enum vchiq_bulk_mode mode,
void *transfer_handle);
// Routine to queue up data ready for transfer to the other (once they have signalled they are ready)
-extern int32_t vchi_bulk_queue_transmit(struct vchi_service *service,
+extern int32_t vchi_bulk_queue_transmit(unsigned handle,
const void *data_src,
uint32_t data_size,
enum vchiq_bulk_mode mode,
#include "vchiq.h"
#include "vchiq_core.h"
-int vchi_queue_kernel_message(struct vchi_service *service, void *data,
- unsigned int size)
+int vchi_queue_kernel_message(unsigned handle, void *data, unsigned int size)
{
enum vchiq_status status;
while (1) {
- status = vchiq_queue_kernel_message(service->handle, data,
- size);
+ status = vchiq_queue_kernel_message(handle, data, size);
/*
* vchiq_queue_message() may return VCHIQ_RETRY, so we need to
* Returns: int32_t - success == 0
*
***********************************************************/
-int32_t vchi_bulk_queue_receive(struct vchi_service *service, void *data_dst,
+int32_t vchi_bulk_queue_receive(unsigned handle, void *data_dst,
uint32_t data_size, enum vchiq_bulk_mode mode,
void *bulk_handle)
{
enum vchiq_status status;
while (1) {
- status = vchiq_bulk_receive(service->handle, data_dst,
- data_size, bulk_handle, mode);
+ status = vchiq_bulk_receive(handle, data_dst, data_size,
+ bulk_handle, mode);
/*
* vchiq_bulk_receive() may return VCHIQ_RETRY, so we need to
* implement a retry mechanism since this function is supposed
* Returns: int32_t - success == 0
*
***********************************************************/
-int32_t vchi_bulk_queue_transmit(struct vchi_service *service,
- const void *data_src,
- uint32_t data_size,
- enum vchiq_bulk_mode mode,
+int32_t vchi_bulk_queue_transmit(unsigned handle, const void *data_src,
+ uint32_t data_size, enum vchiq_bulk_mode mode,
void *bulk_handle)
{
enum vchiq_status status;
while (1) {
- status = vchiq_bulk_transmit(service->handle, data_src,
- data_size, bulk_handle, mode);
+ status = vchiq_bulk_transmit(handle, data_src, data_size,
+ bulk_handle, mode);
/*
* vchiq_bulk_transmit() may return VCHIQ_RETRY, so we need to
*
* Arguments: struct vchiq_instance *instance
* struct service_creation *setup,
- * struct vchi_service **service
+ * unsigned *handle
*
* Description: Routine to open a service
*
*
***********************************************************/
-static struct vchi_service *service_alloc(void)
-{
- return kzalloc(sizeof(struct vchi_service), GFP_KERNEL);
-}
-
-static void service_free(struct vchi_service *service)
-{
- if (service)
- kfree(service);
-}
-
int32_t vchi_service_open(struct vchiq_instance *instance,
- struct vchiq_service_params *params,
- struct vchi_service **service)
+ struct vchiq_service_params *params,
+ unsigned *handle)
{
-
- *service = service_alloc();
- if (*service) {
- enum vchiq_status status;
-
- status = vchiq_open_service(instance, params,
- &((*service)->handle));
- if (status != VCHIQ_SUCCESS) {
- service_free(*service);
- *service = NULL;
- }
- }
-
- return *service ? 0 : -1;
+ return vchiq_open_service(instance, params, handle);
}
EXPORT_SYMBOL(vchi_service_open);
-int32_t vchi_service_close(struct vchi_service *service)
+int32_t vchi_service_close(unsigned handle)
{
- int32_t ret = -1;
-
- if (service) {
- enum vchiq_status status = vchiq_close_service(service->handle);
- if (status == VCHIQ_SUCCESS)
- service_free(service);
-
- ret = status;
- }
- return ret;
+ return vchiq_close_service(handle);
}
EXPORT_SYMBOL(vchi_service_close);
-int32_t vchi_get_peer_version(struct vchi_service *service, short *peer_version)
+int32_t vchi_get_peer_version(unsigned handle, short *peer_version)
{
- int32_t ret = -1;
-
- if (service) {
- enum vchiq_status status;
-
- status = vchiq_get_peer_version(service->handle, peer_version);
- ret = status;
- }
- return ret;
+ return vchiq_get_peer_version(handle, peer_version);
}
EXPORT_SYMBOL(vchi_get_peer_version);
/***********************************************************
* Name: vchi_service_use
*
- * Arguments: struct vchi_service *service
+ * Arguments: unsigned handle
*
* Description: Routine to increment refcount on a service
*
* Returns: void
*
***********************************************************/
-int32_t vchi_service_use(struct vchi_service *service)
+int32_t vchi_service_use(unsigned handle)
{
- int32_t ret = -1;
-
- if (service)
- ret = vchiq_use_service(service->handle);
- return ret;
+ return vchiq_use_service(handle);
}
EXPORT_SYMBOL(vchi_service_use);
/***********************************************************
* Name: vchi_service_release
*
- * Arguments: struct vchi_service *service
+ * Arguments: unsigned handle
*
* Description: Routine to decrement refcount on a service
*
* Returns: void
*
***********************************************************/
-int32_t vchi_service_release(struct vchi_service *service)
+int32_t vchi_service_release(unsigned handle)
{
- int32_t ret = -1;
-
- if (service)
- ret = vchiq_release_service(service->handle);
- return ret;
+ return vchiq_release_service(handle);
}
EXPORT_SYMBOL(vchi_service_release);
};
struct vchiq_mmal_instance {
- struct vchi_service *service;
+ unsigned service_handle;
/* ensure serialised access to service */
struct mutex vchiq_mutex;
/* Dummy receive to ensure the buffers remain in order */
len = 8;
/* queue the bulk submission */
- vchi_service_use(instance->service);
- ret = vchi_bulk_queue_receive(instance->service,
+ vchi_service_use(instance->service_handle);
+ ret = vchi_bulk_queue_receive(instance->service_handle,
msg_context->u.bulk.buffer->buffer,
/* Actual receive needs to be a multiple
* of 4 bytes
VCHIQ_BULK_MODE_CALLBACK,
msg_context);
- vchi_service_release(instance->service);
+ vchi_service_release(instance->service_handle);
if (ret != 0)
pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n",
if (!port->enabled)
return -EINVAL;
- pr_debug("instance:%p buffer:%p\n", instance->service, buf);
+ pr_debug("instance:%u buffer:%p\n", instance->service_handle, buf);
/* get context */
if (!buf->msg_context) {
/* no payload in message */
m.u.buffer_from_host.payload_in_message = 0;
- vchi_service_use(instance->service);
+ vchi_service_use(instance->service_handle);
- ret = vchi_queue_kernel_message(instance->service,
+ ret = vchi_queue_kernel_message(instance->service_handle,
&m,
sizeof(struct mmal_msg_header) +
sizeof(m.u.buffer_from_host));
- vchi_service_release(instance->service);
+ vchi_service_release(instance->service_handle);
return ret;
}
DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len),
">>> sync message");
- vchi_service_use(instance->service);
+ vchi_service_use(instance->service_handle);
- ret = vchi_queue_kernel_message(instance->service,
+ ret = vchi_queue_kernel_message(instance->service_handle,
msg,
sizeof(struct mmal_msg_header) +
payload_len);
- vchi_service_release(instance->service);
+ vchi_service_release(instance->service_handle);
if (ret) {
pr_err("error %d queuing message\n", ret);
port->component->handle, port->handle);
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
pr_debug("%s:result:%d component:0x%x port:%d\n",
__func__, ret, port->component->handle, port->handle);
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
component->inputs, component->outputs, component->clocks);
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
ret = -rmsg->u.component_enable_reply.status;
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
*minor_out = rmsg->u.version.minor;
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
port_action_type_names[action_type], action_type);
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
action_type, connect_component_handle, connect_port_handle);
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
ret, port->component->handle, port->handle, parameter_id);
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
ret, port->component->handle, port->handle, parameter_id);
release_msg:
- vchiq_release_message(instance->service->handle, rmsg_handle);
+ vchiq_release_message(instance->service_handle, rmsg_handle);
return ret;
}
if (mutex_lock_interruptible(&instance->vchiq_mutex))
return -EINTR;
- vchi_service_use(instance->service);
+ vchi_service_use(instance->service_handle);
- status = vchi_service_close(instance->service);
+ status = vchi_service_close(instance->service_handle);
if (status != 0)
pr_err("mmal-vchiq: VCHIQ close failed\n");
if (!instance->bulk_wq)
goto err_free;
- status = vchi_service_open(vchiq_instance, ¶ms, &instance->service);
+ status = vchi_service_open(vchiq_instance, ¶ms,
+ &instance->service_handle);
if (status) {
pr_err("Failed to open VCHI service connection (status=%d)\n",
status);
goto err_close_services;
}
- vchi_service_release(instance->service);
+ vchi_service_release(instance->service_handle);
*out_instance = instance;
return 0;
err_close_services:
- vchi_service_close(instance->service);
+ vchi_service_close(instance->service_handle);
destroy_workqueue(instance->bulk_wq);
err_free:
vfree(instance->bulk_scratch);