void pt3_init_dmabuf(struct pt3_adapter *adap)
{ int idx, ofs;
u8 *p;
idx = 0;
ofs = 0;
p = adap->buffer[0].data; /* mark the whole buffers as "not written yet" */ while (idx < adap->num_bufs) {
p[ofs] = PT3_BUF_CANARY;
ofs += PT3_ACCESS_UNIT; if (ofs >= DATA_BUF_SZ) {
ofs -= DATA_BUF_SZ;
idx++;
p = adap->buffer[idx].data;
}
}
adap->buf_idx = 0;
adap->buf_ofs = 0;
}
void pt3_free_dmabuf(struct pt3_adapter *adap)
{ struct pt3_board *pt3; int i;
pt3 = adap->dvb_adap.priv; for (i = 0; i < adap->num_bufs; i++)
dma_free_coherent(&pt3->pdev->dev, DATA_BUF_SZ,
adap->buffer[i].data, adap->buffer[i].b_addr);
adap->num_bufs = 0;
for (i = 0; i < adap->num_desc_bufs; i++)
dma_free_coherent(&pt3->pdev->dev, PAGE_SIZE,
adap->desc_buf[i].descs, adap->desc_buf[i].b_addr);
adap->num_desc_bufs = 0;
}
int pt3_alloc_dmabuf(struct pt3_adapter *adap)
{ struct pt3_board *pt3; void *p; int i, j; int idx, ofs; int num_desc_bufs;
dma_addr_t data_addr, desc_addr; struct xfer_desc *d;
pt3 = adap->dvb_adap.priv;
adap->num_bufs = 0;
adap->num_desc_bufs = 0; for (i = 0; i < pt3->num_bufs; i++) {
p = dma_alloc_coherent(&pt3->pdev->dev, DATA_BUF_SZ,
&adap->buffer[i].b_addr, GFP_KERNEL); if (p == NULL) goto failed;
adap->buffer[i].data = p;
adap->num_bufs++;
}
pt3_init_dmabuf(adap);
/* build circular-linked pointers (xfer_desc) to the data buffers*/
idx = 0;
ofs = 0;
num_desc_bufs =
DIV_ROUND_UP(adap->num_bufs * DATA_BUF_XFERS, DESCS_IN_PAGE); for (i = 0; i < num_desc_bufs; i++) {
p = dma_alloc_coherent(&pt3->pdev->dev, PAGE_SIZE,
&desc_addr, GFP_KERNEL); if (p == NULL) goto failed;
adap->num_desc_bufs++;
adap->desc_buf[i].descs = p;
adap->desc_buf[i].b_addr = desc_addr;
if (i > 0) {
d = &adap->desc_buf[i - 1].descs[DESCS_IN_PAGE - 1];
d->next_l = lower_32_bits(desc_addr);
d->next_h = upper_32_bits(desc_addr);
} for (j = 0; j < DESCS_IN_PAGE; j++) {
data_addr = adap->buffer[idx].b_addr + ofs;
d = &adap->desc_buf[i].descs[j];
d->addr_l = lower_32_bits(data_addr);
d->addr_h = upper_32_bits(data_addr);
d->size = DATA_XFER_SZ;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.