[PATCH] 3.10 video decoder for SAM9M10

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

blue_z
Location: USA
Posts: 1690
Joined: Thu Apr 19, 2007 10:15 pm

[PATCH] 3.10 video decoder for SAM9M10

Fri Mar 20, 2015 1:23 am

The SAM9M10 has an integrated Hantro 8170 video decoder, but it has previously only been supported AFAIK with Linux 2.6.30-at91, as described in this web page. Those versions of hx170dec.c and memalloc.c do not even seem to be available at the Linux4SAM github, but are part of a legacy "experimental" patch.
This new patch utilizes the vdec and memalloc modules of the SAMA5D4 as released in linux4sam_4.6, which is based on Linux 3.10.

Tested with the gst-plugin-x170 package of Buildroot 2014.11 and fbdevsink video sink on an AT91SAM9G49M10-EK board.
Changes should not break SAMA5D4 builds, but that was not tested due to board unavailability.

sam9m10_vdec.patch (apply to linux4sam_4.6):

Code: Select all

diff -pruN a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
--- a/arch/arm/boot/dts/at91sam9g45.dtsi	2014-11-20 17:11:41.000000000 -0800
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi	2015-02-23 15:37:36.000000000 -0800
@@ -836,6 +836,13 @@
 			interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>;
 			status = "disabled";
 		};
+
+		vdec0: vdec@00900000 {
+			compatible = "on2,hx170dec";
+			reg = <0x00900000 0x100000>;
+			interrupts = <30 IRQ_TYPE_LEVEL_HIGH 4>;
+			status = "disabled";
+		};
 	};
 
 	i2c@0 {
diff -pruN a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts	2014-11-20 17:11:41.000000000 -0800
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts	2015-02-23 15:37:34.000000000 -0800
@@ -14,11 +14,11 @@
 	compatible = "atmel,at91sam9m10g45ek", "atmel,at91sam9g45", "atmel,at91sam9";
 
 	chosen {
-		bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2";
+		bootargs = "mem=128M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2";
 	};
 
 	memory {
-		reg = <0x70000000 0x4000000>;
+		reg = <0x70000000 0x8000000>;
 	};
 
 	clocks {
@@ -182,13 +183,30 @@
 		usb1: ehci@00800000 {
 			status = "okay";
 		};
+
+		vdec0: vdec@00900000 {
+			status = "okay";
+		};
 	};
 
 	leds {
 		compatible = "gpio-leds";
 
-		d8 {
-			label = "d8";
+		d1 {
+			label = "d1";
+			gpios = <&pioD 0 GPIO_ACTIVE_HIGH>;
+			linux,default-trigger = "heartbeat";
+			status = "disabled";
+		};
+
+		d2 {
+			label = "d2";
+			gpios = <&pioD 31 GPIO_ACTIVE_HIGH>;
+			status = "disabled";
+		};
+
+		d3 {
+			label = "d3";
 			gpios = <&pioD 30 GPIO_ACTIVE_HIGH>;
 			linux,default-trigger = "heartbeat";
 		};
diff -pruN a/arch/arm/mach-at91/hx170dec.h b/arch/arm/mach-at91/hx170dec.h
--- a/arch/arm/mach-at91/hx170dec.h	2014-11-20 17:11:41.000000000 -0800
+++ b/arch/arm/mach-at91/hx170dec.h	2015-03-02 18:17:32.000000000 -0800
@@ -45,6 +45,9 @@ struct core_desc
 #define HX170DEC_IOCGHWOFFSET		_IOR(HX170DEC_IOC_MAGIC, 3, unsigned long *)
 #define HX170DEC_IOCGHWIOSIZE		_IOR(HX170DEC_IOC_MAGIC, 4, unsigned int *)
 
+#define HX170DEC_IOC_CLI           	_IO(HX170DEC_IOC_MAGIC,  5)
+#define HX170DEC_IOC_STI           	_IO(HX170DEC_IOC_MAGIC,  6)
+
 #define HX170DEC_IOC_MC_OFFSETS		_IOR(HX170DEC_IOC_MAGIC, 7, unsigned long *)
 #define HX170DEC_IOC_MC_CORES		_IOR(HX170DEC_IOC_MAGIC, 8, unsigned int *)
 #define HX170DEC_IOCS_DEC_PUSH_REG	_IOW(HX170DEC_IOC_MAGIC, 9, struct core_desc *)
diff -pruN a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
--- a/arch/arm/mach-at91/Makefile	2014-11-20 17:11:41.000000000 -0800
+++ b/arch/arm/mach-at91/Makefile	2015-03-05 15:00:52.000000000 -0800
@@ -18,7 +18,7 @@ obj-$(CONFIG_SOC_AT91RM9200)	+= at91rm92
 obj-$(CONFIG_SOC_AT91SAM9260)	+= at91sam9260.o
 obj-$(CONFIG_SOC_AT91SAM9261)	+= at91sam9261.o
 obj-$(CONFIG_SOC_AT91SAM9263)	+= at91sam9263.o
-obj-$(CONFIG_SOC_AT91SAM9G45)	+= at91sam9g45.o
+obj-$(CONFIG_SOC_AT91SAM9G45)	+= at91sam9g45.o memalloc.o vdec_g1.o
 obj-$(CONFIG_SOC_AT91SAM9N12)	+= at91sam9n12.o
 obj-$(CONFIG_SOC_AT91SAM9X5)	+= at91sam9x5.o
 obj-$(CONFIG_SOC_AT91SAM9RL)	+= at91sam9rl.o
diff -pruN a/arch/arm/mach-at91/memalloc.c b/arch/arm/mach-at91/memalloc.c
--- a/arch/arm/mach-at91/memalloc.c	2014-11-20 17:11:41.000000000 -0800
+++ b/arch/arm/mach-at91/memalloc.c	2015-03-05 15:05:40.000000000 -0800
@@ -216,6 +216,7 @@ static const struct vm_operations_struct
 #endif
 };
 
+#ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
 /* This function is based on mmap_mem (drivers/char/mem.c) */
 static int memalloc_mmap (struct file *filp, struct vm_area_struct *vma)
 {
@@ -255,14 +256,17 @@ static int memalloc_mmap (struct file *f
 	}
 	return 0;
 }
+#endif
 
 static struct file_operations memalloc_fops = {
 	.owner          =	THIS_MODULE,
 	.open           =	memalloc_open,
 	.release        =	memalloc_release,
 	.unlocked_ioctl =	memalloc_ioctl,
+#ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
 	.llseek         =	noop_llseek,
 	.mmap           =	memalloc_mmap,
+#endif
 };
 
 static int memalloc_init(void)
@@ -290,6 +294,7 @@ static int memalloc_init(void)
 	}
 
 	m->dev->coherent_dma_mask = DMA_BIT_MASK(32);
+	dev_info(m->dev, "Hantro Memory allocator for VDEC, %s \n", "$Revision: 0.5x $");
 	dev_dbg(m->dev, "allocator with major = %d\n", m->major);
 
 	return 0;
@@ -313,4 +318,4 @@ module_exit(memalloc_exit);
 MODULE_AUTHOR("Hantro Products Oy");
 MODULE_DESCRIPTION("Memory allocator for VDEC");
 MODULE_LICENSE("GPL");
-MODULE_VERSION("0.5");
+MODULE_VERSION("0.5x");
diff -pruN a/arch/arm/mach-at91/vdec_g1.c b/arch/arm/mach-at91/vdec_g1.c
--- a/arch/arm/mach-at91/vdec_g1.c	2014-11-20 17:11:41.000000000 -0800
+++ b/arch/arm/mach-at91/vdec_g1.c	2015-03-02 18:29:30.000000000 -0800
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/clk.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -33,13 +34,23 @@
 #include "hx170dec.h"
 #include "at91_vdec.h"
 
-#define VDEC_MAX_CORES                 1 /* number of cores of the hardware IP */
-#define VDEC_NUM_REGS_DEC             60 /* number of registers of the Decoder part */
-#define VDEC_NUM_REGS_PP              41 /* number of registers of the Post Processor part */
-#define VDEC_DEC_FIRST_REG             0 /* first register (0-based) index */
-#define VDEC_DEC_LAST_REG             59 /* last register (0-based) index */
-#define VDEC_PP_FIRST_REG             60
-#define VDEC_PP_LAST_REG             100
+struct vdec_caps {
+	bool	is_m10;		/* hx170 version of sam9m10 */
+	bool	is_a5d4;	/* hx170 version of sama5d4 */
+	u8	max_cores;	/* number of cores of the hardware IP */
+	u8	dec_last_reg;	/* last Decoder register (0-based) index */
+	u8	pp_last_reg;	/* last Post Processor register (0-based) index */
+	int	dir_abort;	/* bit field in VDEC_DIR */
+	int	max_ioctlnum;
+};
+
+#define VDEC_MAX_CORES		1	/* number of cores of the hardware IP */
+#define VDEC_NUM_REGS_DEC	60	/* number of registers of the Decoder part */
+#define VDEC_NUM_REGS_PP	41	/* number of registers of the Post Processor part */
+#define VDEC_DEC_FIRST_REG	0	/* first register (0-based) index */
+#define VDEC_DEC_LAST_REG	(q->dec_last_reg)
+#define VDEC_PP_FIRST_REG	60
+#define VDEC_PP_LAST_REG	(q->pp_last_reg)
 
 struct vdec_device {
 	void __iomem *mmio_base;
@@ -58,6 +69,7 @@ struct vdec_device {
 	struct file *dec_owner;
 	struct file *pp_owner;
 	u32 regs[VDEC_NUM_REGS_DEC + VDEC_NUM_REGS_PP];
+	struct vdec_caps *caps;
 };
 static struct vdec_device *vdec6731_global;
 
@@ -80,8 +92,7 @@ static int vdec_regs_write(struct vdec_d
 {
 	int i;
 
-	if (copy_from_user(&p->regs[begin], core->regs, (end - begin + 1) * 4))
-	{
+	if (copy_from_user(&p->regs[begin], core->regs, (end - begin + 1) * 4)) {
 		dev_err(p->dev, "%s: copy_from_user failed\n", __func__);
 		return -EFAULT;
 	}
@@ -103,8 +114,7 @@ static int vdec_regs_read(struct vdec_de
 	for (i = end; i >= begin; i--)
 		p->regs[i] = vdec_readl(p, 4 * i);
 
-	if (copy_to_user(core->regs, &p->regs[begin], (end - begin + 1) * 4))
-	{
+	if (copy_to_user(core->regs, &p->regs[begin], (end - begin + 1) * 4)) {
 		dev_err(p->dev, "%s: copy_to_user failed\n", __func__);
 		return -EFAULT;
 	}
@@ -153,9 +163,16 @@ static long vdec_misc_ioctl(struct file 
 	int ret = 0;
 	void __user *argp = (void __user *)arg;
 	struct vdec_device *p = vdec6731_global;
+	struct vdec_caps *q = p->caps;
 	struct core_desc core;
 	u32 reg;
 
+	if (_IOC_NR(cmd) > q->max_ioctlnum) {
+		dev_warn(p->dev, "out-of-range ioctl %x\n", cmd);
+		return -EINVAL;
+	}
+	dev_dbg(p->dev, "ioctl %d\n", _IOC_NR(cmd));
+
 	switch (cmd) {
 		case HX170DEC_IOX_ASIC_ID:
 			reg = vdec_readl(p, VDEC_IDR);
@@ -172,6 +189,18 @@ static long vdec_misc_ioctl(struct file 
 			if (copy_to_user(argp, &p->iosize, sizeof(p->iosize)))
 				ret = -EFAULT;
 			break;
+
+		case HX170DEC_IOC_CLI:
+			if (!q->is_m10)
+				goto version_cap;
+			disable_irq(vdec6731_global->irq);
+			break;
+		case HX170DEC_IOC_STI:
+			if (!q->is_m10)
+				goto version_cap;
+			enable_irq(vdec6731_global->irq);
+			break;
+
 		case HX170DEC_IOC_MC_CORES:
 			if (copy_to_user(argp, &p->num_cores, sizeof(p->num_cores)))
 				ret = -EFAULT;
@@ -279,6 +308,7 @@ static long vdec_misc_ioctl(struct file 
 			break;
 
 		default:
+		version_cap:
 			dev_warn(p->dev, "unknown ioctl %x\n", cmd);
 			ret = -EINVAL;
 	}
@@ -293,11 +323,17 @@ const struct file_operations vdec_misc_f
 	.unlocked_ioctl =	vdec_misc_ioctl,
 };
 
-static struct miscdevice vdec_misc_device = {
+static struct miscdevice *vdec_misc_devicep;
+static struct miscdevice vdec_a5d4_misc_device = {
 	MISC_DYNAMIC_MINOR,
 	"vdec",
 	&vdec_misc_fops
 };
+static struct miscdevice vdec_m10_misc_device = {
+	MISC_DYNAMIC_MINOR,
+	"hx170",
+	&vdec_misc_fops
+};
 
 /*
  * Platform driver related
@@ -340,10 +376,13 @@ static irqreturn_t vdec_isr(int irq, voi
 	return IRQ_HANDLED;
 }
 
+static const struct of_device_id vdec_of_match[];
+
 static int __init vdec_probe(struct platform_device *pdev)
 {
 	struct vdec_device *p;
 	struct resource *res;
+	struct vdec_caps *q;
 	int ret;
 	u32 hwid;
 
@@ -353,10 +392,14 @@ static int __init vdec_probe(struct plat
 		dev_dbg(&pdev->dev, "out of memory\n");
 		return -ENOMEM;
 	}
+	dev_dbg(&pdev->dev, "probe\n");
 
 	p->dev = &pdev->dev;
 	platform_set_drvdata(pdev, p);
 
+	p->caps = q = (struct vdec_caps *)
+		of_match_device(vdec_of_match, &pdev->dev)->data;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	p->mmio_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(p->mmio_base))
@@ -382,7 +425,9 @@ static int __init vdec_probe(struct plat
 	}
 
 	/* Register the miscdevice */
-	ret = misc_register(&vdec_misc_device);
+	vdec_misc_devicep = (q->is_a5d4) ?
+		&vdec_a5d4_misc_device : &vdec_m10_misc_device;
+	ret = misc_register(vdec_misc_devicep);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to register miscdevice\n");
 		return ret;
@@ -405,11 +450,20 @@ static int __init vdec_probe(struct plat
 	clk_enable(p->clk);
 
 	dev_info(&pdev->dev, "VDEC controller at 0x%p, irq = %d, misc_minor = %d\n",
-			p->mmio_base, p->irq, vdec_misc_device.minor);
+			p->mmio_base, p->irq, vdec_misc_devicep->minor);
 
 	/* Reset Asic (just in case..) */
-	vdec_writel(p, VDEC_DIR, VDEC_DIR_ID | VDEC_DIR_ABORT);
+	vdec_writel(p, VDEC_DIR, VDEC_DIR_ID | q->dir_abort);
 	vdec_writel(p, VDEC_PPIR, VDEC_PPIR_ID);
+	if (q->is_m10) {
+		unsigned i;
+		for (i = VDEC_DIR / 4; ++i <= q->dec_last_reg; ) {
+			vdec_writel(p, 4 * i, 0);
+		}
+		for (i = VDEC_PPIR / 4; ++i <= q->pp_last_reg; ) {
+			vdec_writel(p, 4 * i, 0);
+		}
+	}
 
 	hwid = vdec_readl(p, VDEC_IDR);
 	dev_warn(&pdev->dev, "Product ID: %#x (revision %d.%d.%d)\n", \
@@ -423,7 +477,7 @@ static int __init vdec_probe(struct plat
 static int __exit vdec_remove(struct platform_device *pdev)
 {
 	platform_set_drvdata(pdev, NULL);
-	misc_deregister(&vdec_misc_device);
+	misc_deregister(vdec_misc_devicep);
 	return 0;
 }
 
@@ -450,8 +504,29 @@ static int vdec_resume(struct platform_d
 #define	vdec_resume	NULL
 #endif
 
+static struct vdec_caps sama5d4_caps = {
+	.is_m10 = false,
+	.is_a5d4 = true,
+	.max_cores = 1,
+	.dec_last_reg = 59,
+	.pp_last_reg = 100,
+	.dir_abort = 0x20,
+	.max_ioctlnum = HX170DEC_IOC_MAXNR,
+};
+
+static struct vdec_caps at91sam9m10_caps = {
+	.is_m10 = true,
+	.is_a5d4 = false,
+	.max_cores = 1,
+	.dec_last_reg = 50,
+	.pp_last_reg = 99,
+	.dir_abort = 0,
+	.max_ioctlnum = 6,
+};
+
 static const struct of_device_id vdec_of_match[] = {
-	{ .compatible = "on2,g1", .data = NULL },
+	{ .compatible = "on2,g1", .data = &sama5d4_caps },
+	{ .compatible = "on2,hx170dec", .data = &at91sam9m10_caps },
 	{},
 };
 MODULE_DEVICE_TABLE(of, vdec_of_match);
@@ -472,5 +547,5 @@ module_platform_driver_probe(vdec_of_dri
 MODULE_AUTHOR("Hantro Products Oy");
 MODULE_DESCRIPTION("G1 decoder/pp driver");
 MODULE_LICENSE("GPL");
-MODULE_VERSION("0.4");
+MODULE_VERSION("0.4x");
 MODULE_ALIAS("platform:vdec");


**ADDENDUM**

The code above has corrupted tab characters.
The patch file can be downloaded from the attachment below or here.

**ADDENDUM 2**

You need to build and boot the kernel with the Device Tree blob at91sam9m10g45ek.dtb.
This patch has minimal effect if you use a legacy board file for device and driver configuration.
Attachments
sam9m10-vdec.patch.zip
sam9m10_vdec.patch
(3.67 KiB) Downloaded 56 times
Last edited by blue_z on Thu Aug 20, 2015 1:53 am, edited 4 times in total.
alex_sl
Posts: 9
Joined: Fri Feb 24, 2012 6:18 am

Re: [PATCH] 3.10 video decoder for SAM9M10

Wed Apr 08, 2015 10:46 pm

Hello.

I try patch kernel https://github.com/linux4sam/linux-at91 ... 4.6.tar.gz, but obtained the following result:

user@user-desktop:~/at91/linux-at91-linux4sam_4.6$ patch -p1 < ../sam9m10_vdec.patch
patching file arch/arm/boot/dts/at91sam9g45.dtsi
Hunk #1 FAILED at 836.
1 out of 1 hunk FAILED -- saving rejects to file arch/arm/boot/dts/at91sam9g45.dtsi.rej
patching file arch/arm/boot/dts/at91sam9m10g45ek.dts
Hunk #1 FAILED at 14.
Hunk #2 FAILED at 182.
2 out of 2 hunks FAILED -- saving rejects to file arch/arm/boot/dts/at91sam9m10g45ek.dts.rej
patching file arch/arm/mach-at91/hx170dec.h
Hunk #1 FAILED at 45.
1 out of 1 hunk FAILED -- saving rejects to file arch/arm/mach-at91/hx170dec.h.rej
patching file arch/arm/mach-at91/Makefile
Hunk #1 FAILED at 18.
1 out of 1 hunk FAILED -- saving rejects to file arch/arm/mach-at91/Makefile.rej
patching file arch/arm/mach-at91/memalloc.c
Hunk #2 FAILED at 256.
Hunk #3 FAILED at 291.
2 out of 4 hunks FAILED -- saving rejects to file arch/arm/mach-at91/memalloc.c.rej
patching file arch/arm/mach-at91/vdec_g1.c
Hunk #2 succeeded at 34 with fuzz 1.
Hunk #3 FAILED at 69.
Hunk #4 FAILED at 91.
Hunk #5 FAILED at 114.
Hunk #6 FAILED at 164.
Hunk #7 FAILED at 183.
Hunk #8 FAILED at 290.
Hunk #9 FAILED at 304.
Hunk #10 FAILED at 351.
Hunk #11 FAILED at 364.
Hunk #12 FAILED at 393.
Hunk #13 FAILED at 416.
Hunk #14 FAILED at 434.
Hunk #15 FAILED at 461.
patch unexpectedly ends in middle of line
Hunk #16 FAILED at 483.
14 out of 16 hunks FAILED -- saving rejects to file arch/arm/mach-at91/vdec_g1.c.rej

May be you used any other kernel?
blue_z
Location: USA
Posts: 1690
Joined: Thu Apr 19, 2007 10:15 pm

Re: [PATCH] 3.10 video decoder for SAM9M10

Thu Apr 09, 2015 12:17 am

alex_sl wrote:May be you used any other kernel?
No, and that's a rather insulting question.
If you are used to (or at least familiar with) kernel coding style, it's obvious that the indentation has been clobbered.
That's because tab characters cannot be preserved in a post.

Attachments have been inhibited on this site for a while despite a message to the webmaster.

I'll see what can be done with a public site. Otherwise if you're in a rush, the patch could be applied manually.

Regards
alex_sl
Posts: 9
Joined: Fri Feb 24, 2012 6:18 am

Re: [PATCH] 3.10 video decoder for SAM9M10

Thu Apr 09, 2015 7:59 am

In any case, didn't mean to insult you.

Could you please  say what branch should be clone master or linux-3.10-at91. 
Сould you provide the config file for buildroot-2014.11.
blue_z
Location: USA
Posts: 1690
Joined: Thu Apr 19, 2007 10:15 pm

Re: [PATCH] 3.10 video decoder for SAM9M10

Thu Apr 09, 2015 8:34 pm

alex_sl wrote:In any case, didn't mean to insult you.
Then ask a neutral question, such as "Why did the patch file fail?", instead of insinuating someone did something wrong.
What I did do wrong was ignore the tab issue, and that has nothing to do with your guess of the kernel version.

The original post has been updated with a download link.
alex_sl wrote:Could you please  say what branch should be clone master or linux-3.10-at91.
Why do you persist with this kernel issue?
The original post explicitly states twice the at91 release tag and has a link to the download page.

Regards
alex_sl
Posts: 9
Joined: Fri Feb 24, 2012 6:18 am

Re: [PATCH] 3.10 video decoder for SAM9M10

Thu Apr 09, 2015 9:42 pm

Thanks for your help.

Kernel is successfuly patched.

Sory for confused questions, but difficult for me to communicate in English.
alex_sl
Posts: 9
Joined: Fri Feb 24, 2012 6:18 am

Re: [PATCH] 3.10 video decoder for SAM9M10

Sun Apr 12, 2015 9:12 pm

Hi all,

I am compile buildroot-2014.11 with gstreamer support(buildroot_config), kernel linux4sam_4.6 with sam9m10_vdec.patch by blue_z and try playing:
st-launch --gst-debug-level=3 ! filesrc location=/root/1.avi ! avidemux name=demux demux.video_00 ! censored ! x170 output=RGB16 inbuf-thresh=0000 output_width=480 output_height=240 ! fbdevsink device=/dev/fb0

But playing is not started. See log.
Please help with my problem.
blue_z
Location: USA
Posts: 1690
Joined: Thu Apr 19, 2007 10:15 pm

Re: [PATCH] 3.10 video decoder for SAM9M10

Mon Apr 13, 2015 8:34 pm

alex_sl wrote:But playing is not started.
That does not look like an issue with the Hantro video decoder.
Try using your video or this Atmel video with both the HW vdec

Code: Select all

gst-launch filesrc location=MPEG2_480_272.avi ! avidemux name=demux demux.video_00 ! x170 ! fbdevsink
versus a software decoder

Code: Select all

gst-launch-0.10 filesrc location=MPEG2_480_272.avi ! avidemux ! mpeg2dec ! ffmpegcolorspace ! fbdevsink
You will probably have to rebuild to add some missing (bad) plugins for MPEG demuxing and the (ugly) MPEG2 decoder.

Regards
alex_sl
Posts: 9
Joined: Fri Feb 24, 2012 6:18 am

Re: [PATCH] 3.10 video decoder for SAM9M10

Mon Apr 13, 2015 11:30 pm

I rebuild Buildroot-2014.11 whith the MPEG demuxing and MPEG2demux and try using Atmel video.

With software decoder it is ok, CPU load about 90%. But the HW vdec is not working.
LOG

What could be the problem?

Regards
blue_z
Location: USA
Posts: 1690
Joined: Thu Apr 19, 2007 10:15 pm

Re: [PATCH] 3.10 video decoder for SAM9M10

Tue Apr 14, 2015 12:57 am

alex_sl wrote:What could be the problem?
When I enter the same command line from the log, I see the same error.
But when I use the command line that I provided, there's no error and the video plays okay.

Inspection of your command line indicates it is malformed.
The error line in the log

Code: Select all

0:00:00.557082383   481    0x1f800 ERROR           GST_PIPELINE ./grammar.y:862:priv_gst_parse_yyparse: link without source element
apparently refers to the "--gst-debug-level" option, since removing the bang (exclamation point) in the middle of "--gst-debug-level=3 ! filesrc" fixes it for me. You cannot use "--gst-debug-level" as a source element (since it's just a command option), nor can you pipeline the filesrc specification when it has no sink element.

Regards
alex_sl
Posts: 9
Joined: Fri Feb 24, 2012 6:18 am

Re: [PATCH] 3.10 video decoder for SAM9M10

Tue Apr 14, 2015 6:00 pm

I try this command line, but video is not started.

# lsmod
Module                  Size  Used by    Tainted: P
hx170dec                2230  0
# gst-launch filesrc location=MPEG2_480_272.avi ! avidemux name=demux demux.video_00 ! x170 ! fbdevsink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstAviDemux:demux: Internal data stream error.
Additional debug info:
gstavidemux.c(5212): gst_avi_demux_loop (): /GstPipeline:pipeline0/GstAviDemux:demux:
streaming stopped, reason not-negotiated
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
FULL LOG

Could you share your logfile, and may be buildroot config?
alex_sl
Posts: 9
Joined: Fri Feb 24, 2012 6:18 am

Re: [PATCH] 3.10 video decoder for SAM9M10

Wed Apr 15, 2015 10:00 pm

It's may be, because I could not load module (extra/memalloc.ko)?

# modprobe  memalloc.ko
memalloc: module is already loaded
modprobe: can't load module memalloc.ko (extra/memalloc.ko): Invalid argument

On my board 64MB ddr and 32MB sdrsm.
blue_z
Location: USA
Posts: 1690
Joined: Thu Apr 19, 2007 10:15 pm

Re: [PATCH] 3.10 video decoder for SAM9M10

Wed Apr 15, 2015 11:17 pm

alex_sl wrote:I try this command line, but video is not started.

# lsmod
Module                  Size  Used by    Tainted: P
hx170dec                2230  0
That is wrong.
Looks like you have managed to install the old hx170dec decoder driver (which is built as a loadable module).
Whereas the module that you want to use, the 3.10 atmel-vdec driver, is statically linked into the kernel (inspect the patch), so it would not be reported by `lsmod`.
Inspect the syslog to confirm which version of the driver is installed, e.g. ` dmesg | grep vdec`.

Buildroot automatically selects/builds the old Hantro kernel modules when the gst-plugin-x170 is selected. These two Hantro modules stored in /lib/modules/*/extra/ should be ignored since you want/need to use the Atmel drivers.

Review of your Buildroot config reveals that you fail to build the kernel with a Device Tree.
The tipoff that you need DT is that the patch affects .dts and .dtsi files. I've updated the patch post in light of your oversight.

Regards
alex_sl
Posts: 9
Joined: Fri Feb 24, 2012 6:18 am

Re: [PATCH] 3.10 video decoder for SAM9M10

Thu Apr 16, 2015 5:50 pm

Thank you very much for your help!

# dmesg | grep -e vdec -e VDEC
memalloc-cls memalloc: Hantro Memory allocator for VDEC, $Revision: 0.5x $
atmel-vdec 900000.vdec: VDEC controller at 0xc4a00000, irq = 36, misc_minor = 63
atmel-vdec 900000.vdec: Product ID: 0x8170 (revision 1.37.0)

Current CPU load about 1%.

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 6 guests