Lines Matching refs:buf
62 struct saa7164_buffer *buf = NULL;
71 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
72 if (!buf)
75 buf->idx = -1;
76 buf->port = port;
77 buf->flags = SAA7164_BUFFER_FREE;
78 buf->pos = 0;
79 buf->actual_size = params->pitch * params->numberoflines;
80 buf->crc = 0;
82 buf->pci_size = SAA7164_PT_ENTRIES * 0x1000;
83 buf->pt_size = (SAA7164_PT_ENTRIES * sizeof(u64)) + 0x1000;
86 buf->cpu = dma_alloc_coherent(&port->dev->pci->dev, buf->pci_size,
87 &buf->dma, GFP_KERNEL);
88 if (!buf->cpu)
91 buf->pt_cpu = dma_alloc_coherent(&port->dev->pci->dev, buf->pt_size,
92 &buf->pt_dma, GFP_KERNEL);
93 if (!buf->pt_cpu)
97 memset(buf->cpu, 0xff, buf->pci_size);
98 buf->crc = crc32(0, buf->cpu, buf->actual_size);
99 memset(buf->pt_cpu, 0xff, buf->pt_size);
102 __func__, buf, params->numpagetables);
104 buf->cpu, (long)buf->dma, buf->pci_size);
106 buf->pt_cpu, (long)buf->pt_dma, buf->pt_size);
111 *(buf->pt_cpu + i) = buf->dma + (i * 0x1000); /* TODO */
113 i, buf->pt_cpu, (u64)*(buf->pt_cpu));
120 dma_free_coherent(&port->dev->pci->dev, buf->pci_size, buf->cpu,
121 buf->dma);
123 kfree(buf);
125 buf = NULL;
127 return buf;
130 int saa7164_buffer_dealloc(struct saa7164_buffer *buf)
134 if (!buf || !buf->port)
136 dev = buf->port->dev;
139 __func__, buf);
141 if (buf->flags != SAA7164_BUFFER_FREE)
144 dma_free_coherent(&dev->pci->dev, buf->pci_size, buf->cpu, buf->dma);
145 dma_free_coherent(&dev->pci->dev, buf->pt_size, buf->pt_cpu,
146 buf->pt_dma);
148 kfree(buf);
168 int saa7164_buffer_activate(struct saa7164_buffer *buf, int i)
170 struct saa7164_port *port = buf->port;
178 buf->idx = i; /* Note of which buffer list index position we occupy */
179 buf->flags = SAA7164_BUFFER_BUSY;
180 buf->pos = 0;
184 saa7164_writel(port->bufptr32h + ((sizeof(u32) * 2) * i), buf->pt_dma);
187 dprintk(DBGLVL_BUF, " buf[%d] offset 0x%llx (0x%x) buf 0x%llx/%llx (0x%x/%x) nr=%d\n",
188 buf->idx,
195 buf->idx);
204 struct saa7164_buffer *buf;
233 buf = list_entry(c, struct saa7164_buffer, list);
235 BUG_ON(buf->flags != SAA7164_BUFFER_FREE);
238 saa7164_buffer_activate(buf, i);
253 struct saa7164_user_buffer *buf;
255 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
256 if (!buf)
259 buf->data = kzalloc(len, GFP_KERNEL);
261 if (!buf->data) {
262 kfree(buf);
266 buf->actual_size = len;
267 buf->pos = 0;
268 buf->crc = 0;
271 __func__, buf);
273 return buf;
276 void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf)
278 if (!buf)
281 kfree(buf->data);
282 buf->data = NULL;
284 kfree(buf);