@@ -979,6 +979,27 @@ void cx25821_dev_unregister(struct cx25821_dev *dev)
979979}
980980EXPORT_SYMBOL (cx25821_dev_unregister );
981981
982+ int cx25821_riscmem_alloc (struct pci_dev * pci ,
983+ struct cx25821_riscmem * risc ,
984+ unsigned int size )
985+ {
986+ __le32 * cpu ;
987+ dma_addr_t dma = 0 ;
988+
989+ if (NULL != risc -> cpu && risc -> size < size )
990+ pci_free_consistent (pci , risc -> size , risc -> cpu , risc -> dma );
991+ if (NULL == risc -> cpu ) {
992+ cpu = pci_zalloc_consistent (pci , size , & dma );
993+ if (NULL == cpu )
994+ return - ENOMEM ;
995+ risc -> cpu = cpu ;
996+ risc -> dma = dma ;
997+ risc -> size = size ;
998+ }
999+ return 0 ;
1000+ }
1001+ EXPORT_SYMBOL (cx25821_riscmem_alloc );
1002+
9821003static __le32 * cx25821_risc_field (__le32 * rp , struct scatterlist * sglist ,
9831004 unsigned int offset , u32 sync_line ,
9841005 unsigned int bpl , unsigned int padding ,
@@ -1035,7 +1056,7 @@ static __le32 *cx25821_risc_field(__le32 * rp, struct scatterlist *sglist,
10351056 return rp ;
10361057}
10371058
1038- int cx25821_risc_buffer (struct pci_dev * pci , struct btcx_riscmem * risc ,
1059+ int cx25821_risc_buffer (struct pci_dev * pci , struct cx25821_riscmem * risc ,
10391060 struct scatterlist * sglist , unsigned int top_offset ,
10401061 unsigned int bottom_offset , unsigned int bpl ,
10411062 unsigned int padding , unsigned int lines )
@@ -1059,7 +1080,7 @@ int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
10591080 instructions = fields * (1 + ((bpl + padding ) * lines ) / PAGE_SIZE +
10601081 lines );
10611082 instructions += 2 ;
1062- rc = btcx_riscmem_alloc (pci , risc , instructions * 12 );
1083+ rc = cx25821_riscmem_alloc (pci , risc , instructions * 12 );
10631084
10641085 if (rc < 0 )
10651086 return rc ;
@@ -1146,7 +1167,7 @@ static __le32 *cx25821_risc_field_audio(__le32 * rp, struct scatterlist *sglist,
11461167}
11471168
11481169int cx25821_risc_databuffer_audio (struct pci_dev * pci ,
1149- struct btcx_riscmem * risc ,
1170+ struct cx25821_riscmem * risc ,
11501171 struct scatterlist * sglist ,
11511172 unsigned int bpl ,
11521173 unsigned int lines , unsigned int lpi )
@@ -1163,7 +1184,7 @@ int cx25821_risc_databuffer_audio(struct pci_dev *pci,
11631184 instructions = 1 + (bpl * lines ) / PAGE_SIZE + lines ;
11641185 instructions += 1 ;
11651186
1166- rc = btcx_riscmem_alloc (pci , risc , instructions * 12 );
1187+ rc = cx25821_riscmem_alloc (pci , risc , instructions * 12 );
11671188 if (rc < 0 )
11681189 return rc ;
11691190
@@ -1179,13 +1200,13 @@ int cx25821_risc_databuffer_audio(struct pci_dev *pci,
11791200}
11801201EXPORT_SYMBOL (cx25821_risc_databuffer_audio );
11811202
1182- int cx25821_risc_stopper (struct pci_dev * pci , struct btcx_riscmem * risc ,
1203+ int cx25821_risc_stopper (struct pci_dev * pci , struct cx25821_riscmem * risc ,
11831204 u32 reg , u32 mask , u32 value )
11841205{
11851206 __le32 * rp ;
11861207 int rc ;
11871208
1188- rc = btcx_riscmem_alloc (pci , risc , 4 * 16 );
1209+ rc = cx25821_riscmem_alloc (pci , risc , 4 * 16 );
11891210
11901211 if (rc < 0 )
11911212 return rc ;
@@ -1211,7 +1232,8 @@ void cx25821_free_buffer(struct videobuf_queue *q, struct cx25821_buffer *buf)
12111232 videobuf_waiton (q , & buf -> vb , 0 , 0 );
12121233 videobuf_dma_unmap (q -> dev , dma );
12131234 videobuf_dma_free (dma );
1214- btcx_riscmem_free (to_pci_dev (q -> dev ), & buf -> risc );
1235+ pci_free_consistent (to_pci_dev (q -> dev ),
1236+ buf -> risc .size , buf -> risc .cpu , buf -> risc .dma );
12151237 buf -> vb .state = VIDEOBUF_NEEDS_INIT ;
12161238}
12171239
0 commit comments