linux kernel and multimedia

14
Aug 17, 2013 Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co. Not to be used for commercial purpose without getting permission All information, opinions and ideas herein are exclusively the author's own opinion Linux Kernel and Multimídia Mauro Carvalho Chehab Linux Kernel Maintainer of the Media Subsystem Linux Kernel Expert Samsung Open Source Group

Upload: samsung-open-source-group

Post on 07-May-2015

421 views

Category:

Technology


1 download

DESCRIPTION

Linux Kernel Multmedia Subsystem maintainer and Samsung OSG team member Mauro Chehab talks about how the multimedia subsystem is architected and contributed to in the Linux Kernel.

TRANSCRIPT

Page 1: Linux Kernel and Multimedia

Aug 17, 2013

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Not to be used for commercial purpose without getting permissionAll information, opinions and ideas herein are exclusively the author's own opinion

Linux Kernel and Multimídia

Mauro Carvalho Chehab

Linux Kernel Maintainer of the Media SubsystemLinux Kernel Expert

Samsung Open Source Group

Page 2: Linux Kernel and Multimedia

2

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Linux is Everywhere

Page 3: Linux Kernel and Multimedia

3

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

The Linux Kernel Devel Model● Kernel is the core of the operational system that runs a Linux system

● Its development is dictated by the community, not by someone or some company

– If someone (and/or their company) wants a feature, submit a patch

● The community reviews the patch. If community is happy, it gets merged

● The development community is huge and open

– All discussions are via mailing lists (generally hosted at vger.kernel.org);

– IRC (and physical meetings) help to get agreements on more polemic items

● A new Linux Kernel version is released on every ~2 months

– After a new release, 2 weeks are used to merge the features for the next one. This period of time is called: “merge window”;

– A variable period (typically 8 weeks) is used to review the code. After each week, a new release candidate is released (so, about 7 rc's and a final version).

● Contributions are open to everyone, and patches are publicly reviewed

● Subsystem maintainers are responsible to collect the accepted patches, do a final review and submit them to Linus Torvards (the creator of Linux).

Page 4: Linux Kernel and Multimedia

4

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Development model of the Kernel

Page 5: Linux Kernel and Multimedia

5

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Some devel stats on Kernel 3.10Most active 3.10 developers

By changed lines392 2.9%Joe Perches 34561 4.5%299 2.2% 18739 2.4%293 2.2% 18690 2.4%

Alex Elder 268 2.0%Larry Finger 17222 2.2%205 1.5% 16610 2.2%202 1.5% 12879 1.7%192 1.4% 12838 1.7%174 1.3%Paul Zimmerman 12637 1.6%159 1.2% 12518 1.6%

Mauro Carvalho Chehab 158 1.2% 11116 1.4%139 1.0% 11107 1.4%138 1.0%Mauro Carvalho Chehab 9726 1.3%

Eduardo Valentin 138 1.0% 9258 1.2%112 0.8% 8960 1.2%

Lee Jones 111 0.8%Lee Jones 8598 1.1%99 0.7% 8305 1.1%98 0.7% 8094 1.0%97 0.7% 7546 1.0%

Mark Brown 97 0.7% 7510 1.0%Johannes Berg 96 0.7% 7428 1.0%

By changesetsH Hartley SweetenJingoo Han Hans VerkuilHans Verkuil Kent Overstreet

Al Viro Greg Kroah-HartmanFelipe Balbi Shawn GuoSachin Kamat Dave ChinnerLaurent PinchartJohan Hovold H Hartley Sweeten

Al ViroWei Yongjun Andrey SmirnovArnd Bergmann

Laurent PinchartAxel Lin Jussi Kivilinna

Lars-Peter Clausen Sylwester NawrockiKuninori Morimoto Artem BityutskiyTejun Heo Dave Airlie

Guenter RoeckSanjay Lal

source: http://lwn.net/Articles/555867/

Total of 1,374 developers and 13.500 changesets In blue: media developers

Page 6: Linux Kernel and Multimedia

6

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

How to start contributing● RTFM: there are several documents inside the Kernel source explaining the proccess:

– /Documentation/HOWTO

● Main view for new developers

– /Documentation/CodingStyle

● Describes the coding style used by the Linux Kernel

– /Documentation/SubmittingPathes e SubmittingDrivers

● General procedures for submittins patches/drivers

– It should be noticed that each subsystem may have additional rules

– /MAINTAINERS:

– Show the subsystem maintainers, driver maintainer and mailing lists that should be used to send patches

● There are two scripts that help to:

– Check the coding style (checkpatch.pl)

– Check to whom a patch should be sent (get_maintainer.pl)

Page 7: Linux Kernel and Multimedia

7

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Kernel API's for media devices● Video4Linux API (version 2)

– For video inputs/outputs and radio, video and analog TV device control

– Extending it for Software Digital Radio is currently being discussed

● DVB API (version 5)

– For digital TV inputs

● Remote Controller / Input evdev APIs

– For Remote Controllers and webcam/grabber buttons

● The Advanced Linux Sound Architecture (ALSA)

– For audio inputs, outputs, mixers (and sequencers)

● Media Controller API

– To control complex devices with configurable pipelines

– Used only on embeeded devices and on UVC (USB Video Class)

– Subdev API

● To control each single logical element on complex devices

Page 8: Linux Kernel and Multimedia

9

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Patch custodity chainconfirming that the pach

is GPL plus acks, reviews,Tests, etc.

Example of a new patchSubject: uvc: more buffersDate: Fri, 09 Aug 2013 12:11:36 -0000From: Oliver Neukum <[email protected]>To: [email protected] , [email protected]

This is necessary to let the new generation of camerasfrom LiteOn used in Haswell ULT notebook operate. Otherwisethe images will be truncated.

Signed-off-by: Oliver Neukum <[email protected]>

diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.hindex 9e35982..9f1930b 100644--- a/drivers/media/usb/uvc/uvcvideo.h+++ b/drivers/media/usb/uvc/uvcvideo.h@@ -114,9 +114,9 @@ /* Number of isochronous URBs. */ #define UVC_URBS 5 /* Maximum number of packets per URB. */-#define UVC_MAX_PACKETS 32+#define UVC_MAX_PACKETS 128 /* Maximum number of video buffers. */-#define UVC_MAX_VIDEO_BUFFERS 32+#define UVC_MAX_VIDEO_BUFFERS 128 /* Maximum status buffer size in bytes of interrupt URB. */ #define UVC_MAX_STATUS_SIZE 16

Source:https://patchwork.linuxtv.org/patch/19656/

Patch summary: what it does

Mailing List of the subsystem

Driver maintainer

main author

Patch description: why it is needed and

how was done

Unified diff of the changes

Page 9: Linux Kernel and Multimedia

10

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Steps for writing/submitting (1)● 1) Get a copy of the latest development tree:

– http://git.linuxtv.org/media_tree.git (for a media patch)

● 2) Write and test the changes

● 3) generate the patch

$ git commit -a

– write a proper summary, descriptions and add your SOB

$ git show > my_changes.patch

● 3) Check if CodingStyle was not violated or if it doesn't have some common mistakes:

$ ./script/checkpatch.pl my_changes.patch

– Fix patch until checkpatch.pl is happy and test it again

● 4) Send it to the maintainers

– Use get_maintainers.pl to know to whom address the email

$ ./script/get_maintainers.pl my_changes.patch

Page 10: Linux Kernel and Multimedia

11

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Steps for writing/submitting (2)$ ./scripts/get_maintainer.pl /tmp/uvc-more-buffers.patch

Laurent Pinchart <[email protected]> (maintainer:USB VIDEO CLASS)

Mauro Carvalho Chehab <[email protected]> (maintainer:MEDIA INPUT INFRA...)

[email protected] (open list:USB VIDEO CLASS)

[email protected] (open list)

● In the specific case of media drivers, don't c/c the maintainer. If everything is ok in the patch, it will appear in a few at patchwork:

– https://patchwork.linuxtv.org/project/linux-media/list/

● Also, in general, don't copy LKML (linux-kernel). That's the last resort when there's no specific subsystem mailing list.

● Stuff not maintained and without any subsystem maintainer should be submitted to Andrew Morton <[email protected]>.

Page 11: Linux Kernel and Multimedia

12

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Now, what happens?● Wait for people to review it. It may take some time, as Kernel developers are

generally busy with other stuff

– Everybody can review a patch, including you.

● If you find a problem, write an email describing what you noticed.

● If you tested the patch, reply to it with

Tested-by: you <your.email>● If you reviewed the patch but didn't test, reply to it with

Reviewed-by: you <your.email>● Driver/system maintainers can also reply with Acked-by if they're ok if

someone else would review and apply that patch.

– A patch with reviews/tests will likely flow quicker than one that would depend solely on the driver maintainer to test

● The driver maintainer will get your patch, test or review and either apply or ask someone else to apply it;

● The patch will be applied by a sub-maintainer or by a subsystem maintainer;

● The subsystem maintainer will send it to Linus on the next merge window.

Page 12: Linux Kernel and Multimedia

13

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

Some literature● You should read:

– The pertinent docs at Kernel source tree, under Documentation/ directory

● Some books for starting working on Kernel:

– Corbet, J; Rubini, A; Kroah-Hartman, Greg, Linux Device Drivers, 3rd edition, O'Reilly, 2005

– There's an online version: http://lwn.net/Kernel/LDD3/

– Love, Robert, Linux Kernel Development, 3rd edition, Addison-Wesley, 2010

– Daniel P. Bovet, Marco Cesati, Understanding the Linux Kernel, 3rd edition, O'Reilly, 2005

– Venkateswaran, Sreekrishnan, Essential Linux Device Drivers, Prentice Hall, 2008

– Web useful resources:

● http://kernelnewbies.org/

● http://lwn.net

– V4L2 articles:● http://lwn.net/Articles/203924/

Page 13: Linux Kernel and Multimedia

14

Open Source Group – Silicon Valley © 2013 SAMSUNG Electronics Co.

References on media drivers● How to get and test the latest drivers:

– See http://git.linuxtv.org/media_build.git

● Userspace tools:

– Remote controller/V4L/DVD: http://git.linuxtv.org/v4l-utils.git

● Wiki pages: http://linuxtv.org/wiki/

● Mailing list: [email protected]

● IRC channel: irc.freenode.net

– channels #v4l and #linuxtv

– Can be assessed via http://webchat.freenode.net/