platform-drivers: msm: sps: return number of unused descriptors
Client driver has a new feature requirement to acquire the number of unused descriptors in the descriptor FIFO of a pipe; Add this support in SPS driver. Change-Id: Idf02308f6011973c2ad4fea2a50134b48062b953 Signed-off-by: Yan He <yanhe@codeaurora.org>
This commit is contained in:
@@ -1205,4 +1205,17 @@ int sps_phy2h(u32 phys_addr, u32 *handle);
|
||||
int sps_setup_bam2bam_fifo(struct sps_mem_buffer *mem_buffer,
|
||||
u32 addr, u32 size, int use_offset);
|
||||
|
||||
/**
|
||||
* Get the number of unused descriptors in the descriptor FIFO
|
||||
* of a pipe
|
||||
*
|
||||
* @h - client context for SPS connection end point
|
||||
*
|
||||
* @desc_num - number of unused descriptors
|
||||
*
|
||||
* @return 0 on success, negative value on error
|
||||
*
|
||||
*/
|
||||
int sps_get_unused_desc_num(struct sps_pipe *h, u32 *desc_num);
|
||||
|
||||
#endif /* _SPS_H_ */
|
||||
|
||||
@@ -1351,6 +1351,32 @@ int sps_free_mem(struct sps_pipe *h, struct sps_mem_buffer *mem_buffer)
|
||||
}
|
||||
EXPORT_SYMBOL(sps_free_mem);
|
||||
|
||||
/**
|
||||
* Get the number of unused descriptors in the descriptor FIFO
|
||||
* of a pipe
|
||||
*
|
||||
*/
|
||||
int sps_get_unused_desc_num(struct sps_pipe *h, u32 *desc_num)
|
||||
{
|
||||
struct sps_pipe *pipe = h;
|
||||
struct sps_bam *bam;
|
||||
int result;
|
||||
|
||||
SPS_DBG("sps:%s.", __func__);
|
||||
|
||||
bam = sps_bam_lock(pipe);
|
||||
if (bam == NULL)
|
||||
return SPS_ERROR;
|
||||
|
||||
result = sps_bam_pipe_get_unused_desc_num(bam, pipe->pipe_index,
|
||||
desc_num);
|
||||
|
||||
sps_bam_unlock(bam);
|
||||
|
||||
return result;
|
||||
}
|
||||
EXPORT_SYMBOL(sps_get_unused_desc_num);
|
||||
|
||||
/**
|
||||
* Register a BAM device
|
||||
*
|
||||
|
||||
@@ -1960,3 +1960,29 @@ int sps_bam_pipe_timer_ctrl(struct sps_bam *dev,
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of unused descriptors in the descriptor FIFO
|
||||
* of a pipe
|
||||
*/
|
||||
int sps_bam_pipe_get_unused_desc_num(struct sps_bam *dev, u32 pipe_index,
|
||||
u32 *desc_num)
|
||||
{
|
||||
u32 sw_offset, peer_offset, fifo_size;
|
||||
u32 desc_size = sizeof(struct sps_iovec);
|
||||
struct sps_pipe *pipe = dev->pipes[pipe_index];
|
||||
|
||||
if (pipe == NULL)
|
||||
return SPS_ERROR;
|
||||
|
||||
fifo_size = pipe->desc_size;
|
||||
|
||||
sw_offset = bam_pipe_get_desc_read_offset(dev->base, pipe_index);
|
||||
peer_offset = bam_pipe_get_desc_write_offset(dev->base, pipe_index);
|
||||
|
||||
if (sw_offset <= peer_offset)
|
||||
*desc_num = (peer_offset - sw_offset) / desc_size;
|
||||
else
|
||||
*desc_num = (peer_offset + fifo_size - sw_offset) / desc_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -545,4 +545,20 @@ int sps_bam_set_satellite(struct sps_bam *dev, u32 pipe_index);
|
||||
int sps_bam_pipe_timer_ctrl(struct sps_bam *dev, u32 pipe_index,
|
||||
struct sps_timer_ctrl *timer_ctrl,
|
||||
struct sps_timer_result *timer_result);
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of unused descriptors in the descriptor FIFO
|
||||
* of a pipe
|
||||
*
|
||||
* @dev - pointer to BAM device descriptor
|
||||
*
|
||||
* @pipe_index - pipe index
|
||||
*
|
||||
* @desc_num - number of unused descriptors
|
||||
*
|
||||
*/
|
||||
int sps_bam_pipe_get_unused_desc_num(struct sps_bam *dev, u32 pipe_index,
|
||||
u32 *desc_num);
|
||||
|
||||
#endif /* _SPSBAM_H_ */
|
||||
|
||||
Reference in New Issue
Block a user