Skip to contentSkip to conversation

2.6.10 zr36067 driver - ppc/be port

PATCH New Ronald S. Bultje 1 participant 1 message Dec 29, 2004 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 2.6.10 zr36067 driver - ppc/be port

Hi Linus/Andrew,

Attached patch adds some host<->le conversion functions for 32-bit integers. The hardware expects 32-bit integers, which the host does not always provide. With the attached patch, the hardware runs fine on PPC hardware as well.

Original patch by Ben Capper (see CC).

Regards,

Ronald

Ben Capper <[email protected]>

Signature · 1 line
Ronald S. Bultje <[email protected]>
drivers/media/video/zoran_device.c +18 -13
Index: linux-2.6.10/drivers/media/video/zoran_device.c
===================================================================
@@ -32,6 +32,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/vmalloc.h>
+#include <linux/byteorder/generic.h>
 
 #include <linux/interrupt.h>
 #include <linux/proc_fs.h>
@@ -758,7 +759,7 @@
 		zr->jpg_buffers.buffer[i].state = BUZ_STATE_USER;	/* nothing going on */
 	}
 	for (i = 0; i < BUZ_NUM_STAT_COM; i++) {
-		zr->stat_com[i] = 1;	/* mark as unavailable to zr36057 */
+		zr->stat_com[i] = cpu_to_le32(1);	/* mark as unavailable to zr36057 */
 	}
 }
 
@@ -1163,20 +1164,20 @@
 			/* fill 1 stat_com entry */
 			i = (zr->jpg_dma_head -
 			     zr->jpg_err_shift) & BUZ_MASK_STAT_COM;
-			if (!(zr->stat_com[i] & 1))
+			if (!(zr->stat_com[i] & cpu_to_le32(1)))
 				break;
 			zr->stat_com[i] =
-			    zr->jpg_buffers.buffer[frame].frag_tab_bus;
+			    cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus);
 		} else {
 			/* fill 2 stat_com entries */
 			i = ((zr->jpg_dma_head -
 			      zr->jpg_err_shift) & 1) * 2;
-			if (!(zr->stat_com[i] & 1))
+			if (!(zr->stat_com[i] & cpu_to_le32(1)))
 				break;
 			zr->stat_com[i] =
-			    zr->jpg_buffers.buffer[frame].frag_tab_bus;
+			    cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus);
 			zr->stat_com[i + 1] =
-			    zr->jpg_buffers.buffer[frame].frag_tab_bus;
+			    cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus);
 		}
 		zr->jpg_buffers.buffer[frame].state = BUZ_STATE_DMA;
 		zr->jpg_dma_head++;
@@ -1213,7 +1214,7 @@
 			i = ((zr->jpg_dma_tail -
 			      zr->jpg_err_shift) & 1) * 2 + 1;
 
-		stat_com = zr->stat_com[i];
+		stat_com = le32_to_cpu(zr->stat_com[i]);
 
 		if ((stat_com & 1) == 0) {
 			return;
@@ -1309,7 +1310,7 @@
 					for (i = 0;
 					     i < zr->jpg_buffers.num_buffers;
 					     i++) {
-						if (zr->stat_com[j] ==
+						if (le32_to_cpu(zr->stat_com[j]) ==
 						    zr->jpg_buffers.
 						    buffer[i].
 						    frag_tab_bus) {
@@ -1321,7 +1322,6 @@
 				printk("\n");
 			}
 		}
-
 		/* Find an entry in stat_com and rotate contents */
 		{
 			int i;
@@ -1334,9 +1334,9 @@
 				      zr->jpg_err_shift) & 1) * 2;
 			if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS) {
 				/* Mimic zr36067 operation */
-				zr->stat_com[i] |= 1;
+				zr->stat_com[i] |= cpu_to_le32(1);
 				if (zr->jpg_settings.TmpDcm != 1)
-					zr->stat_com[i + 1] |= 1;
+					zr->stat_com[i + 1] |= cpu_to_le32(1);
 				/* Refill */
 				zoran_reap_stat_com(zr);
 				zoran_feed_stat_com(zr);
@@ -1355,12 +1355,17 @@
 				int j;
 				u32 bus_addr[BUZ_NUM_STAT_COM];
 
+				/* Here we are copying the stat_com array, which
+				 * is already in little endian format, so
+				 * no endian conversions here
+				 */
 				memcpy(bus_addr, zr->stat_com,
 				       sizeof(bus_addr));
 				for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
 					zr->stat_com[j] =
 					    bus_addr[(i + j) &
 						     BUZ_MASK_STAT_COM];
+						     
 				}
 				zr->jpg_err_shift += i;
 				zr->jpg_err_shift &= BUZ_MASK_STAT_COM;
@@ -1564,7 +1569,7 @@
 						int i;
 						strcpy(sv, sc);
 						for (i = 0; i < 4; i++) {
-							if (zr->stat_com[i] & 1)
+							if (le32_to_cpu(zr->stat_com[i]) & 1)
 								sv[i] = '1';
 						}
 						sv[4] = 0;
@@ -1592,7 +1597,7 @@
 					       ZR_DEVNAME(zr), zr->jpg_seq_num);
 					for (i = 0; i < 4; i++) {
 						printk(" %08x",
-						       zr->stat_com[i]);
+						       le32_to_cpu(zr->stat_com[i]));
 					}
 					printk("\n");
 				}
drivers/media/video/zoran_driver.c +33 -23

119 lines not on this page · raw message