/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* dcam1394 driver. Video frame ring buffer support.
*/
#include <sys/ddidmareq.h>
#include <sys/inttypes.h>
#include <sys/tnf_probe.h>
/*
* ring_buff_create
*
* - alloc ring_buff_t structure
* - init ring_buff's num_buffs, buff_num_bytes, num_read_ptrs,
* read_ptr_pos
* - alloc (num buffs) entries in ring_buff's buff_info_array_p
*
* - for each buff
* - alloc DMA handle; store DMA handle in buff's buff_info_array_p
* - alloc mem for DMA transfer; store base addr, data access handle
* in buff's buff_info_array_p entry
* - bind alloc'ed mem to DMA handle; store assoc info in buff's
* buff_info_array_p entry
*/
{
int i, rc;
num_bytes = sizeof (ring_buff_t);
ring_buff_p->write_ptr_pos = 0;
ring_buff_p->num_read_ptrs = 0;
for (i = 0; i < MAX_NUM_READ_PTRS; i++) {
}
if ((ddi_dma_alloc_handle(
NULL,
return (NULL);
}
if (ddi_dma_mem_alloc(
&(buff_info_p->kaddr_p),
&(buff_info_p->real_len),
/*
* Print a warning, this triggered the bug
* report #4423667. This call can fail if
* the memory tests are being run in sunvts.
* The fact is, this code is doing the right
* thing. I added an error message, so that
* future occurrences can be dealt with directly.
* This is not a bug... The vmem test in sunvts
*/
"ddi_dma_mem_alloc() failed in ring_buff_create(),"\
" insufficient memory resources.\n");
return (NULL);
}
NULL,
if (rc != DDI_DMA_MAPPED) {
return (NULL);
}
}
return (ring_buff_p);
}
/*
* ring_buff_free
*/
void
{
int i;
if (ring_buff_p == NULL) {
return;
}
for (i = 0; i < ring_buff_p->num_buffs; i++) {
}
}
}
/*
* ring_buff_read_ptr_add
*/
int
{
int i;
int read_ptr_id;
read_ptr_id = -1;
for (i = 0; i < MAX_NUM_READ_PTRS; i++) {
ring_buff_p->read_ptr_pos[i] = 0;
read_ptr_id = i;
break;
}
}
return (read_ptr_id);
}
/*
* ring_buff_read_ptr_remove
*/
int
{
return (0);
}
/*
* ring_buff_read_ptr_buff_get
*
* Return pointer to buffer that a read pointer associated with the
* ring buffer is pointing to.
*/
{
return (buff_info_p);
}
/*
* ring_buff_read_ptr_pos_get
*/
{
}
/*
* ring_buff_read_ptr_incr
*/
void
{
#if defined(_ADDL_RING_BUFF_CHECK)
#endif /* _ADDL_RING_BUFFER_CHECK */
/*
* increment the read pointer based on read_ptr_incr_val
* which can vary from 1 to 10
*/
/* get current read pointer pos */
#if defined(_ADDL_RING_BUFF_CHECK)
return;
}
/* calculate new read pointer position */
/* there is still some valid frame data */
(read_ptr_pos +
} else {
/*
* we have skipped beyond available frame
* data, so the buffer is empty
*/
}
} else {
/*
* since read pointer is ahead of write pointer,
* it becomes easier to check for new read
* pointer position if we pretend that our data
* buffer is linear instead of circular
*/
/* there is still some valid frame data */
(read_ptr_pos +
} else {
/*
* we have skipped beyond available
* frame data, so the buffer is empty
*/
}
}
#endif /* _ADDL_RING_BUFF_CHECK */
}
/*
* ring_buff_write_ptr_pos_get
*/
{
return (ring_buff_p->write_ptr_pos);
}
/*
* ring_buff_write_ptr_incr
*/
void
{
}