1 Mauro Carvalho Chehab <mchehab@infradead.org>
2 Updated on 2010 January 30
4 This file describes the general procedures used by the LinuxTV team (*)
5 and by the v4l-dvb community.
7 (*) This is just an aka for the main developers involved in V4L/DVB
8 drivers. They are a volunteer and unremunerated group of people that
9 have the common interest of providing a good support on Linux for
10 receiving and capturing video streams from webcams, analog TV, digital
11 TV and radio broadcast AM/FM.
16 Part I - Patch management on LinuxTV
17 1. A brief introduction about patch management
18 2. Git and Mercurial trees hosted on LinuxTV site
19 3. Git and Mercurial trees' relationships with v4l/dvb development
20 4. Patch submission process overall
21 5. Other Git trees used for v4l/dvb development
22 6. Other Mercurial trees used for v4l/dvb development
25 1. Kernel development procedures at the kernel upstream
26 1.1 Subsystem procedures for merging patches upstream
27 1.2 A practical example
28 1.3 Patches for stable
29 2. Kernel development procedures for V4L/DVB
30 2.1 Fixes and linux-next patches
31 2.2 How to solve those issues?
32 3. How to submit a -git pull request
33 3.1 Tags that a patch receive after its submission
34 4. Patches submitted via email
37 Part III - Best Practices
38 1. Community best practices
39 2. Mercurial specific procedures
40 3. Knowing about newer patches committed at the development repositories
41 4. Patch submission from the community
42 5. Identifying regressions with Mercurial
43 6. Identifying regressions with Git
44 7. Creating a newer driver
48 ===================================
49 PART I. PATCH MANAGEMENT ON LINUXTV
50 ===================================
53 1. A brief introduction about patch management
54 ===========================================
56 V4L/DVB development is based on modern SCM (Source Code Management) systems
57 that fits better into kernel development model.
59 At the beginning, the usage CVS for of a SCM (Source Code Management) were
60 choosen on V4L/DVB. Both of the original V4L and DVB trees were developed with
61 the help of cvs. On that time, upstream Linux kernel used to have another tree
64 In 2005, Upstream Kernel development model changed to use git (a SCM tool
65 developed by Linus Torvalds, the inventor and main maintainer of the Linux
68 Also in 2005, both V4L and DVB trees got merged into one cvs repository, and
69 the community discussed about what would be the better SCM solution. It were
70 mainly availed the usage of svn, hg and git. On that time, both hg and git were
71 new technologies, based on the concept of a distributed SCM, where there's no
72 need to go to the server every time a command is used at the SCM. This speeds
73 up the development time, and allows descentralized development.
75 Mercurial used to be stable and had more projects using, while git were giving
76 its first steps, being used almost only by the Linux Kernel, and several distros
77 didn't use to package it. Git objects were stored uncompressed, generating very
78 large trees. Also, -git tools were complex to use, and some "porcelain" packages
79 were needed, in order to be used by a normal user.
81 So, the decision was made to use Mercurial. However, as time goes by, git got
82 much more eyes than any other SCM, having all their weakness solved, and being
83 developed really fast. Also, it got adopted by several other projects, due to
84 its capability and its number of features.
86 Technically speaking, -git is currently the most advanced distributed
87 open-source SCM application available today.
89 Yet, Mercurial has been doing a very good job maintaining the V4L/DVB trees,
90 and, except for a few points, it does the job.
92 However, the entire Linux Kernel development happens around -git. Even the ones
93 that were adopting other tools (like -alsa, that used to have also Mercurial
94 repositories) migrated to -git.
96 Despite all technical advantages, the rationale for the migration to git is
97 quite simple: converting patches between different repositories and SCM tools
98 cause development and merge delays, may cause patch mangling and eats lot of
99 the time for people that are part of the process.
101 Also, every time a patch needs to touch on files outside the incomplete tree
102 used at the subsystem, an workaround need to be done, in order to avoid troubles
103 and to be able to send the patch upstream.
105 So, it is simpler to just use -git.
107 2. Git and Mercurial trees hosted on LinuxTV site
108 ==============================================
110 A list of current available Mercurial repositories used on LinuxTV is available at:
111 http://linuxtv.org/hg/
114 A list of current available Git repositories used on LinuxTV is available
116 http://git.linuxtv.org
118 3. Git and Mercurial trees' relationships with v4l/dvb development
119 ===============================================================
121 The main subsystem kernel trees are hosted at http://git.kernel.org. Each tree
122 is owned by a maintainer. In the case of LinuxTV, the subsystem maintainer is
123 Mauro Carvalho Chehab, who owns all sybsystem trees.
125 The main kernel tree is owned by Linus Torvalds, being located at:
126 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git
128 The subsystem maintainer's master tree is located at:
129 http://git.kernel.org/?p=linux/kernel/git/mchehab/linux-2.6.git
131 The subsystem maintainer's tree with development patches that aren't ready yet
132 for upstream is handled at:
133 http://git.linuxtv.org/git/v4l-dvb.git
135 The main function of this tree is to merge patches received via email and from
136 other Git and Mercurial repositories and to test the entire subsystem with the
139 The subsystem maintainer's tree with development patches that will be sent soon
140 to upstream is located at:
141 http://git.linuxtv.org/git/fixes.git
143 There is also an experimental tree, that contains all experimental patches
144 from all subsystem trees, called linux-next. Its purpose is to check in
145 advance if patches from different trees would conflict. The main tree for
146 linux-next is owned by Stephen Rothwell and it is located at:
147 http://git.kernel.org/?p=linux/kernel/git/sfr/linux-next.git
149 Warning: linux-next is meant to be used by developers. As it may contain broken
150 +++++++ patches on several subsystems, it may cause damage if used on
153 The subsystem maintainer's linux-next tree is located at:
154 http://www.kernel.org/git/?p=linux/kernel/git/mchehab/linux-next.git
156 In general, it contains a replica of the contents of the development tree.
158 Michael Krufky maintains a backport tree, containing a subset of the
159 patches from the subsystem tree that are meant to be sent to kernel
161 http://git.kernel.org/http://git.kernel.org/?p=linux/kernel/git/mkrufky/
164 In order to allow testing the LinuxTV drivers with older kernels, a backport
165 tree is maintained by Douglas Schilling Landgraf <dougsland at redhat dot com>.
167 The backport tree is at:
168 http://linuxtv.org/hg/v4l-dvb
170 Basically, all patches added at -git
171 are manually imported on this tree, that also contains some logic to allow
172 compilation of the core system since kernel 2.6.16. It should be noticed,
173 however, that some drivers may require newer kernels in order to compile.
175 Also, those backports are developped as best efforts, and are mainly against
176 upstream stable kernels, so they may not compile with distro-patched kernels,
177 nor they are meant to offer production level of support. So, if you need to
178 run any prodution machine, you should really be using a Linux distribution
179 that offers support for the drivers you need and has a Quality Assurance
180 process when doing backports. You were warned.
182 Users are welcome to use, test and report any issues via the mailing
183 lists or via the Kernel Bug Tracker, available at:
184 http://bugzilla.kernel.org
186 4. Patch submission process overall
187 ================================
189 When a developer believes that there are done to be merged, he sends a request
190 for the patches to get merged at the v4l-dvb.git tree, at the linux-media at
191 vger.kernel.org (the main mailing list for LinuxTV).
193 The patches are analyzed and, if they look ok, they got merged into v4l-dvb.git.
195 Currently, there are thre ways to submit a patch:
196 as an email, with the subject [PATCH];
197 as a hg pull request, with the subject [PULL];
198 as a git pull request, with the subject [GIT FIXES ...] or [GIT UPDATES ...]
200 If the patch is developed against the Mercurial repositories, it is converted
201 to the format git expects and have any backport code removed.
203 No matter how the patch is received, after being checked and accepted by the maintainer,
204 the patch will receive the maintainer's Certificate of Origin (Signed-off-by,
205 as explained later within this document), and will be added at:
207 http://git.linuxtv.org/git/v4l-dvb.git
209 Later, it will be backported to the -hg tree.
211 The community also reviews the patches and may send emails informing that the
212 patch has problems or were tested/acked. When those reviews happen after the
213 patch merge at the tree, the patch is modified before its upstream submission.
215 Also, the maintainer may need to modify the patch at his trees, in order to
216 fix conflicts that may happen with the patch.
218 The subsystem maintainer, when preparing the kernel patches to be sent
219 to mainstream, send the patches first to linux-next tree, and waits for some
220 to receive contributions from other upstream developers. If, during that period,
221 he notices a problem, he may correct the patch at his upstream submission tree.
223 5. Other Git trees used for v4l/dvb development
224 ============================================
226 V4L/DVB Git trees are hosted at
229 There are a number of trees there each owned by a developer of the LinuxTV team.
231 The submission emails are generated via the usage of git request-pull, as
232 described on part II.
234 Git is a distributed SCM, which means every developer gets his
235 own full copy of the repository (including the complete revision
236 history), and can work and commit locally without network connection.
237 The resulting changesets can then be exchanged between repositories and
238 finally merged into a common repository on linuxtv.org.
240 The Git trees used on LinuxTV have the entire Linux Kernel tree and history
241 since kernel 2.6.12. So, it generally takes some time to update it at the
244 There are several good documents on how to use -git, including:
246 http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
247 http://www.kernel.org/pub/software/scm/git/docs
249 6. Other Mercurial trees used for v4l/dvb development
250 ==================================================
252 V4L/DVB Mercurial trees are hosted at
253 http://linuxtv.org/hg.
255 There are a number of trees there each owned by a developer of the LinuxTV team.
257 A script called v4l/scripts/hg-pull-req.pl is included that will generate this
258 request, providing a list of patches that will be pulled, links to each
259 patch, and a diffstat of the all patches. It will work best if Hg has
260 been configured with the correct username (also used by the commit
261 message generator) and push path. The script is designed to be easy to
262 modify to produce text for a given contributor's style.
264 It is good practice that each developer will have at least one tree
265 called 'v4l-dvb', which keeps their patches, and periodically update
266 this tree with the master tree's patches.
268 Mercurial is a distributed SCM, which means every developer gets his
269 own full copy of the repository (including the complete revision
270 history), and can work and commit locally without network connection.
271 The resulting changesets can then be exchanged between repositories and
272 finally merged into a common repository on linuxtv.org.
274 There are some tutorials, FAQs and other valuable information at
275 http://selenic.com/mercurial/
283 1. Kernel development procedures at the kernel upstream
284 ====================================================
286 It is important that people understand how upstream development works.
288 Kernel development has 2 phases:
290 a) a merge window typically with 2 weeks (although Linus is gave some
291 indications that he may reduce it on 2.6.34), starting with the release of
292 a new kernel version;
294 b) the -rc period, where the Kernel is tested and receive fixes.
296 The length of the -rc period depends on the number and relevance of the fixes.
297 Considering the recent history, it ranges from -rc6 to -rc8, where each -rc
300 Those are the latest -rc kernels since 2.6.12:
301 kernel latest -rc version
324 In general, the announcement of a new -rc kernel gives some hints when that
325 -rc kernel may be the last one.
327 1.1. Subsystem procedures for merging patches upstream
328 =================================================
330 The required procedure on subsystem trees is that:
332 a) During -rc period (e.g. latest main kernel available is 2.6.x, the latest
333 -rc kernel is 2.6.[x+1]-rc<y>):
335 * fix patches for the -rc kernel (2.6.[x+1]) should be sent upstream,
336 being a good idea to send them for some time at linux-next tree, allowing
337 other people to test it, and check for potential conflicts with the other
339 * patches for 2.6.[x+2] should be sent to linux-next.
341 b) the release of 2.6.[x+1] kernel:
343 * closes the -rc period and starts the merge window.
345 c) During the merge window:
347 * the patch that were added on linux-next during the -rc period for
348 2.6.[x+2] should be sent upstream;
349 * new non-fix patches should be hold until the next -rc period starts, so,
350 they'll be added on 2.6.[x+3];
351 * fix patches for 2.6.[x+2] should go to linux-next, wait for a few days
352 and then send upstream.
354 d) the release of 2.6.[x+2]-rc1 kernel:
356 * the merge window has closed. No new features are allowed.
357 * the patches with new features that arrived during the merge window
358 will be moved to linux-next
360 1.2. A practical example
363 Considering that, at the time this document were written, the last main release
364 is 2.6.32, and the latest -rc release is 2.6.33-rc5, this means that:
366 * Stable patches, after adding upstream, are being received for 2.6.32
368 * Bug fixes are being received for kernel 2.6.33;
369 * New feature patches are being received for kernel 2.6.34.
371 After the release of kernel 2.6.33, starts the period for receiving patches
374 In other words, the features being developed are always meant to be included on
377 In the specific case of new drivers that don't touch on existing features, it
378 could be possible to send it during the -rc period, but it is safer to assume
379 that those drivers should follow the above procedure, as a later submission may
382 1.3. Patches for stable
385 Sometimes, a fix patch corrects a problem that happens also on stable kernels
386 (e. g. on kernel 2.6.x or even 2.6.y, where y < x). In this case, the patch
387 should be sent to stable@kernel.org, in order to be added on stable kernels.
389 In the case of git-submitted patches with fixes, that also need to be send to
390 stable, all the developer needs to do is to add, a the patch description:
392 CC: stable.kernel.org
394 At the moment the patch reaches upstream, a copy of the patch will be
395 automatically be sent to the stable maintainer and will be considered for
396 inclusion on the next stable kernel (2.6.x.y).
398 2. Kernel development procedures for V4L/DVB
399 =========================================
401 The upsteam procedures should be followed by every kernel subsystem. The
402 subsystems have their own specific procedures detailing how the development
403 patches are handled before arriving upstream. In the case of v4l/dvb, those
404 are the used procedures.
406 2.1. Fixes and linux-next patches
407 ============================
409 One of the big problems of our model used in the past by the subsystem, based on
410 one Mercurial tree, is that there were just one tree/branch for everything. This
411 makes hard to send some fix patches for 2.6.[x+1], as they may have conflicts
412 with the patches for 2.6.[x+2]. So, when the conflict is simple to solve, the
413 patch is sent as fixes. Otherwise, the patch generally needed to hold to the
414 next cycle. The fix patches used to get a special tag, added by the developer
415 ("Priority: high", in the body of the description), to give a hint to the
416 subsystem maintainer that the patch should be sent upstream.
418 Unfortunately, sometimes people mark the driver with the wrong tag. For example,
419 a patch got merged on Jan, 22 2010 that marked with "high". However, that patch
420 didn't apply at the fixes tree, because it fix a regression introduced by a
421 driver that weren't merged upstream yet.
423 2.2. How to solve those issues?
424 ==========================
426 Well, basically, the subsystem should work with more than one tree (or branch),
427 on upstream submission:
429 * a tree(branch) with the fix patches;
430 * a tree(branch) with the new feature patches.
432 So, the subsystem uses two development -git trees:
434 * http://linuxtv.org/git//v4l-dvb.git - for patches that will be sent to the
435 [x+2] kernel (and merged at upstream linux-next tree)
437 * http://linuxtv.org/git//fixes.git - for bug patches that will be sent to
438 the [x+1] kernel (also, patches that need to go to both [x+1] and [x])
440 While the patches via -hg, due to the merge conflicts its mentioned, the better
441 is that, even those developers that prefer to develop patches use the old way,
442 to send the fix patches via -git. This way, if is there a conflict, he is the
443 one that can better solve it. Also, it avoids the risk of a patch being wrongly
446 Also, after having a patch added on one of the above trees, it can't simply
447 remove it, as others will be cloning that tree. So, the only option would be to
448 send a revert patch, causing the patch history to be dirty and could be
449 resulting on some troubles when submitting upstream. I've seen some nacks on
450 receiving patches upstream from dirty git trees. So, we should really avoid
453 3. how to submit a -git pull request
454 =================================
456 As the same git tree may have more than one branch, and we'll have 2 -git trees
457 for upstream, it is required that people specify what should be done. The
458 internal maintainer's workflow is based on different mail queues for each type
459 of requesting received.
461 There are some scripts to automate the process, so it is important that everyone
462 that sends -git pull do it at the same way.
464 So, a pull request to be send with the following email tags:
466 From: <your real email>
467 Subject: [GIT FIXES FOR 2.6.33] Fixes for driver cx88
468 To: linux-media@vger.kernel.org
470 From: <your real email>
471 Subject: [GIT PATCHES FOR 2.6.34] Updates for the driver saa7134
472 To: linux-media@vger.kernel.org
474 The from line may later be used by the git mailbomb script to send you a copy
475 when the patch were committed, so it should be your real email.
477 The indication between [] on the subject will be handled by the mailer scripts
478 to put the request at the right queue. So, if tagged wrong, it may not be
481 Don't send a copy of the pull to the maintainer addresses. The pull will be
482 filtering based on the subject and on the mailing list. If you send a c/c to the
483 maintainer, it will be simply discarded.
485 NEVER send a copy of any pull request to a subscribers-only mailing list.
486 Everyone is free to answer to the email, reviewing your patches. Don't penalty
487 people that wants to contribute with you with SPAM bouncing emails, produced by
488 subscribers only lists.
490 When a patch touches on other subsystem codes, please copy the other subsystem
491 maintainers. This is important for patches that touches on arch files, and also
492 for -alsa non-trivial patches.
494 The email should be generated with the usage of git request-pull:
496 git request-pull $ORIGIN $URL
498 where $ORIGIN is the commit hash of the tree before your patches, and $URL is
499 the URL for your repository.
501 For example, for the patches merged directly from -hg at the -git trees on Jan,
502 22 2010, the above commands produced:
504 The following changes since commit 2f52713ab3cb9af2eb0f9354dba1421d1497f3e7:
506 V4L/DVB: 22-kHz set_tone fix for NetUP Dual DVB-S2-CI card. 22kHz logic controlled by demod
508 are available in the git repository at:
510 git://linuxtv.org/v4l-dvb.git master
513 V4L/DVB: cx25840, v4l2-subdev, ivtv, pvrusb2: Fix ivtv/cx25840 tinny audio
514 V4L/DVB: ivtv: Adjust msleep() delays used to prevent tinny audio and PCI bus hang
515 V4L/DVB: cx18-alsa: Initial non-working cx18-alsa files
516 V4L/DVB: cx18-alsa: Add non-working cx18-alsa-pcm.[ch] files to avoid data loss
518 Devin Heitmueller (20):
519 V4L/DVB: xc3028: fix regression in firmware loading time
520 V4L/DVB: cx18: rename cx18-alsa.c
521 V4L/DVB: cx18: make it so cx18-alsa-main.c compiles
522 V4L/DVB: cx18: export a couple of symbols so they can be shared with cx18-alsa
523 V4L/DVB: cx18: overhaul ALSA PCM device handling so it works
524 V4L/DVB: cx18: add cx18-alsa module to Makefile
525 V4L/DVB: cx18: export more symbols required by cx18-alsa
526 V4L/DVB: cx18-alsa: remove unneeded debug line
527 V4L/DVB: cx18: rework cx18-alsa module loading to support automatic loading
528 V4L/DVB: cx18: cleanup cx18-alsa debug logging
529 V4L/DVB: cx18-alsa: name alsa device after the actual card
530 V4L/DVB: cx18-alsa: remove a couple of warnings
531 V4L/DVB: cx18-alsa: fix memory leak in error condition
532 V4L/DVB: cx18-alsa: fix codingstyle issue
533 V4L/DVB: cx18-alsa: codingstyle fixes
534 V4L/DVB: cx18: codingstyle fixes
535 V4L/DVB: cx18-alsa: codingstyle cleanup
536 V4L/DVB: cx18-alsa: codingstyle cleanup
537 V4L/DVB: cx18: address possible passing of NULL to snd_card_free
538 V4L/DVB: cx18-alsa: Fix the rates definition and move some buffer freeing code.
541 V4L/DVB: ivtv: Fix race condition for queued udma transfers
543 Igor M. Liplianin (4):
544 V4L/DVB: Add Support for DVBWorld DVB-S2 PCI 2004D card
545 V4L/DVB: dm1105: connect splitted else-if statements
546 V4L/DVB: dm1105: use dm1105_dev & dev instead of dm1105dvb
547 V4L/DVB: dm1105: use macro for read/write registers
550 V4L/DVB: Compro S350 GPIO change
552 drivers/media/common/tuners/tuner-xc2028.c | 11 +-
553 drivers/media/dvb/dm1105/Kconfig | 1 +
554 drivers/media/dvb/dm1105/dm1105.c | 501 ++++++++++++++-------------
555 drivers/media/video/cx18/Kconfig | 11 +
556 drivers/media/video/cx18/Makefile | 2 +
557 drivers/media/video/cx18/cx18-alsa-main.c | 293 ++++++++++++++++
558 drivers/media/video/cx18/cx18-alsa-mixer.c | 191 ++++++++++
559 drivers/media/video/cx18/cx18-alsa-mixer.h | 23 ++
560 drivers/media/video/cx18/cx18-alsa-pcm.c | 353 +++++++++++++++++++
561 drivers/media/video/cx18/cx18-alsa-pcm.h | 27 ++
562 drivers/media/video/cx18/cx18-alsa.h | 59 ++++
563 drivers/media/video/cx18/cx18-driver.c | 40 ++-
564 drivers/media/video/cx18/cx18-driver.h | 10 +
565 drivers/media/video/cx18/cx18-fileops.c | 6 +-
566 drivers/media/video/cx18/cx18-fileops.h | 3 +
567 drivers/media/video/cx18/cx18-mailbox.c | 46 +++-
568 drivers/media/video/cx18/cx18-streams.c | 2 +
569 drivers/media/video/cx25840/cx25840-core.c | 48 ++-
570 drivers/media/video/ivtv/ivtv-irq.c | 5 +-
571 drivers/media/video/ivtv/ivtv-streams.c | 6 +-
572 drivers/media/video/ivtv/ivtv-udma.c | 1 +
573 drivers/media/video/pvrusb2/pvrusb2-hdw.c | 1 +
574 drivers/media/video/saa7134/saa7134-cards.c | 4 +-
575 include/media/v4l2-subdev.h | 1 +
576 24 files changed, 1380 insertions(+), 265 deletions(-)
577 create mode 100644 drivers/media/video/cx18/cx18-alsa-main.c
578 create mode 100644 drivers/media/video/cx18/cx18-alsa-mixer.c
579 create mode 100644 drivers/media/video/cx18/cx18-alsa-mixer.h
580 create mode 100644 drivers/media/video/cx18/cx18-alsa-pcm.c
581 create mode 100644 drivers/media/video/cx18/cx18-alsa-pcm.h
582 create mode 100644 drivers/media/video/cx18/cx18-alsa.h
584 This helps to identify what's expected to be found at the -git tree and to
585 double check if the merge happened fine.
587 3.1. Tags that a patch receive after its submission
588 ==============================================
590 This is probably the most complex issue to solve.
592 Signed-off-by/Acked-by/Tested-by/Nacked-by tags may be received after a patch or
593 a -git submission. This can happen even while the patch is being tested at
594 linux-next, from people reporting problems on the existing patches, or reporting
595 that a patch worked fine.
597 Also, the driver maintainer and the subsystem maintainer that is committing
598 those patches should sign each one, to indicate that he reviewed and has
601 Currently, if a new tag is added to a committed patch, its hash will change.
602 There were some discussions at Linux Kernel Mailing List about allowing adding
603 new tags on -git without changing the hash, but I think this weren't implemented
606 The same problem occurs with -hg, but, as -hg doesn't support multiple branches
607 (well, it has a "branch" command, but the concept of branch there is different),
608 it was opted that the -hg trees won't have all the needed SOBs. Instead, those
609 would be added only at the submission tree.
611 With -git, a better procedure can be used:
613 The developer may have two separate branches on his tree. For example, let's
614 assume that the developer has the following branches on his tree:
616 * media-master (associated with "linuxtv" remote)
620 His development happens on devel branch. When the patches are ready to
621 submission will be copied into a new for_submission branch: git branch
624 And a pull request from the branch "for_submission" will be sent.
626 Eventually, he'll write new patches on his devel branch.
628 After merged, the developer updates the linuxtv remote and drops the
629 for_submission branch. This way, "media-master" will contain his patches that
630 got a new hash, due to the maintainer's SOB. However, he has some new patches on
631 his devel, that applies over the old hashes.
633 Fortunately, git has a special command to automatically remove the old objects:
636 All the developer needs to do is to run the commands bellow:
637 git remote update # to update his remotes, including "linuxtv"
638 git checkout devel # move to devel branch
639 git pull . media-master # to make a recursive merge from v4l/dvb upstream
640 git rebase media-master # to remove the legacy hashes
642 After this, his development branch will contain only upstream patches + the new
643 ones he added after sending the patches for upstream submission.
645 4. Patches submitted via email
646 ===========================
648 All valid patches submitted via email to linux-media at vger.kernel.org are
649 automatically stored at http://patchwork.kernel.org/project/linux-media/list. A
650 patch, to be valid, should be in diff unified format. If you're using a -git
651 tree, the simplest way to generate unified diff patches is to run:
655 If you're writing several patches, the better is to create a tag or a branch for
656 the changes you're working. After that, you can use
658 git format-patch <origin_branch>
660 to create the patches for email submission.
665 Suppose that the -git tree were created with:
667 git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git v4l-dvb
669 git remote add linuxtv git://linuxtv.org/v4l-dvb.git
671 git checkout -b media-master linuxtv/master
674 Before start working, you need to create your work branch:
676 git branch work media-master
678 And move the working copy to the "work" branch:
682 Some changes were done at the driver and saved by commit:
686 When the patches are ready for submission via email, all that is needed is to
689 git format-patch work
691 The command will create a series of emails bodies, one file per email.
693 Just send the email with the patch inlined for it to ge caught by patchwork.
695 BE CAREFUL: several emailers including Thunderdird breaks long lines, causing
697 In the specific case of Thunderbird, an extension is needed to send the
698 patches, called Asalted Patches:
699 https://hg.mozilla.org/users/clarkbw_gnome.org/asalted-patches/
702 =========================
703 Part III - BEST PRACTICES
704 =========================
707 1. Community best practices
708 ========================
710 From accumulated experience, there are some basic rules that should
711 be followed by the community:
713 a) Every developer should follow the "rules of thumb" of kernel development
714 stated at Linux source code, especially those stated at kernel,
717 Documentation/SubmittingPatches
718 Documentation/SubmittingDrivers
719 Documentation/SubmitChecklist
720 Documentation/CodingStyle
722 b) All commits at the trees should have a consistent message, describing the
725 When a patch is generated against the git tree, the better is to commit it
729 This will automatically add all existing patches that got modified and add
730 your Certificate of Origin (Signed-off-by).
732 It will open an editor for you to provide a description of the patch.
733 The first line is a short summary describing why the patch is needed, and
734 the following lines describe what and how the patch does that.
736 If you've added new files, don't forget to add them before the commit, with:
737 git add <the name of each file you've created>
739 Before committing a patch, you need to check it with checkpatch.pl tool. This
741 git diff | ./script/checkpatch.pl -
743 c) All patches are requested to have their coding style validated by using
744 ./script/checkpatch.pl.
746 On Git, the script checks not only the patch against coding style, but
747 also checks for the usage of functions that are marked to be removed
750 d) All patches shall have a Developer's Certificate of Origin
751 version 1.1 in the commit log or the email description, signed by the
752 patch authors, as postulated in the Linux kernel source at:
754 Documentation/SubmittingPatches
756 This is done by adding Signed-off-by: fields to the commit message.
758 It is not acceptable to use fake signatures, e.g.:
760 Signed-off-by: Fake me <me@snakeoilcompany.com>
762 The email must be a valid one.
763 The author that is submitting the email should be at the button of
764 the author's signed-off-by (SOB) block. Other SOBs or Acked-by: will be
765 added at the bottom, marking that somebody else reviewed the patch.
767 Each person who is in the kernel patch submission chain (driver author
768 and/or driver maintainer, subsystem/core maintainers, etc) will
769 review each patch. If they agree, the patch will be added to their
770 trees and signed. Otherwise, they may comment on the patch, asking
773 e) Although not documented at kernel's Documentation/, a common kernel
774 practice is to use Acked-by: and Tested-by: tags.
776 An Acked-by: tag usually means that the acked person didn't write the
777 patch, nor is in the chain responsible for sending the patch to
778 kernel, but reviewed the patch and agreed that it was good.
780 A Tested-by: tag is a stronger variation of Acked-by. It means that the
781 person not only reviewed the patch, but also successfully tested it.
783 The better is that the patch author submitting his patches via git or hg
784 to add any acked-by/tested-by tags he received. When a patch is sent via
785 email, Patchwork tool will automatically include any such tags it receives
786 in reply together with the patch.
788 It is also common to receive acks after having a patch inserted at the
789 maintainer's trees. In this case, the ack will be added only at -git tree
790 used to send patches upstream.
792 f) Another kernel's practice that is agreed to be good is that a
793 patchset should be reviewed/tested by other developers. So, a new
794 tag should be used by testers/reviewers. So, reviewers are welcome.
795 After reviewing a patchset, please send an e-mail indicating that, if
796 possible, with some additional data about the testing, with the tag:
797 Reviewed-by: My Name <myemail@mysite.com>
798 This is particularly important for Kernel to userspace ABI changes.
800 g) If the patch also affects other parts of kernel (like ALSA
801 or i2c), it is required that, when submitting upstream, the patch
802 also goes to the maintainers of that subsystem. To do this, the
803 developer shall copy the interested parties.
805 When submitting a patch via e-mail, it is better to copy all interested
806 parties directly, by adding them as cc's to the email itself.
808 Please note that those changes generally require ack from the
809 other subsystem maintainers. So, the best practice is to first ask
810 for their acks, then commit to the development tree or send the
811 patch via email with their Acked-by: already included.
813 NOTE: at Mercurial tree, it used to be possible to use the cc: meta tag to
814 warn other users/mailing lists about a patch submission. However, this only
815 works when a patch is merged at the backport tree. So, it's usage is
816 considered obsolete nowadays.
818 h) If the patch modifies the V4L or DVB API's (for example, modifying
819 include/linux/videodev2.h) file, then it must verify be verified that the
820 V4L2 specification document still builds. Of course, any changes you make
821 to the public V4L2 API must be documented anyway.
823 Currently, this can be done only with the Mercurial trees, by running:
826 Patches are welcome to migrate this functionality to upstream kernel DocBook
829 i) By submitting a patch to the subsystem maintainer, either via email
830 or via pull request, the patch author(s) are agreeing that the
831 submitted code will be added on Kernel, and that the submitted code
832 are being released as GPLv2. The author may grant additional licenses
833 to the submitted code (for example, using dual GPL/BSD) or GPLv2 or
834 later. If no specific clause are added, the added code will be
835 assumed as GPLv2 only.
837 j) "Commit earlier and commit often". This is a common used rule at
838 Kernel. This means that a sooner submission of a patch will mean that
839 a review can happen sooner, and help the develop to address the
840 comments. This helps to reduce the life-cycle for having a changeset
841 committed at kernel at the proper time. It also means that the one
842 changeset should ideally address just one issue. So, mixing different
843 things at the same patch should be avoided.
845 k) Sometimes, the maintainer may need to slightly modify patches you receive
846 in order to merge them, because the code is not exactly the same in your
847 tree and the submitters'. In order to save time, it may do the changes and
848 add a line before his SOB, as stated on Documentation/SubmittingPatches,
849 describing what he did to merge it. Something like:
851 Signed-off-by: Random J Developer <random@developer.example.org>
852 [lucky@maintainer.example.org: struct foo moved from foo.c to foo.h]
853 Signed-off-by: Lucky K Maintainer <lucky@maintainer.example.org>
855 2. Mercurial specific procedures
856 =============================
858 a) With the -hg trees, some scripts are used to generate the patch. This is
863 This will run some scripts that check changed files, correct
864 bad whitespace and prepare the last Signed-off-by: field, as
865 described below. A good comment will have a brief
866 description at the first line, up to 68 characters wide, a blank
867 line, the patch author's name on the third line, a blank line, and
868 then a brief description, with no more than 80 chars per line, e. g.:
870 This patch does nothing
872 From: nowhere <nowhere@noplace.org>
874 This is just a sample commit comment, just for reference purposes.
876 This "patch" does nothing.
880 Signed-off-by: nowhere <nowhere@noplace.org>
882 All lines starting with # and all lines starting with HG: will be
883 removed from the Mercurial commit log.
885 *WARNING* Be careful not to leave the first line blank, otherwise hg
886 will leave subject blank.
888 From: line shouldn't be omitted, since it will be used for the
889 patch author when converting to -git.
891 Priority: meta-tag will be used as a hint to the subsystem maintainer, to
892 help him to identify if the patch is an improvement or board addition
893 ("normal"), that will follow the normal lifecycle of a patch (e.g. will be
894 sent upstream on the next merge tree), if the patch is a bug fix tree for a
895 while without merging upstream ("low").
896 Valid values for "Priority:" are "low", "normal" and "high".
898 b)For "make commit" to work properly, the HGUSER shell environment var should
899 be defined (replacing the names at the right):
901 HGUSER="My Name <myemail@mysite.com>"
903 If HGUSER is not set, then, if present, the username defined in the
904 user's ~/.hgrc file will be used. Use of the .hgrc file is preferred
905 over the HGUSER variable according to the hg man page.
907 This name will be used for both the user metadata in the Hg commit
908 log and the initial values of the "From:" and "Signed-off-by:" lines
909 in the pre-made commit message.
911 It is also possible to use a different login name at the site
912 hosting the repository, by using:
914 CHANGE_LOG_LOGIN=my_log_name
916 With this, "make push" will use my_log_name, instead of the name for
917 the current Unix user.
919 Don't forget to export the vars at shell, with something like:
921 export CHANGE_LOG_LOGIN HGUSER
923 It is strongly recommended to have those lines in .bashrc or .profile.
925 b) the CodingStyle compliance check on Mercurial trees are done when
926 "make check" is called. This happens also when "make commit" is done.
928 There's a copy of the kernel tool at the mercurial repository. However,
929 this copy may be outdated. So, by default, it will try to use the newest
930 version of the script, between the one found at the kernel tree and
933 It is always a good idea to use in-kernel version, since additional tests
934 are performed when called from the kernel tree. Yet, those tests are
935 dependent of the kernel version, so, the results of checkpatch may not
936 reflect the latest rules/deprecated functions, if you're not using -git.
938 It is possible to override the in-kernel checkpatch.pl location, by using
939 the CHECKPATCH shell environment var to something like:
940 CHECKPATCH="/usr/src/linux/scripts/checkpatch.pl"
943 c) Sometimes, mainstream changes affect the v4l-dvb tree, and must be
944 backported to the v4l-dvb tree. This kind of commit to the Mercurial
945 tree should follow the rules above and should also have the line:
949 Patches with this line will not be submitted upstream.
951 d) Sometimes it is necessary to introduce some testing code inside a
952 module or remove parts that are not yet finished. Also, compatibility
953 tests may be required to provide backporting.
955 To allow compatibility tests, linux/version.h is automatically
956 included by the building system. This allows adding tests like:
958 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
959 #include <linux/mutex.h>
961 #include <asm/semaphore.h>
964 It should be noticed, however, that an explicit inclusion of
965 linux/version.h is required if it is needed to use KERNEL_VERSION()
966 macro (this is required, for example, by V4L2 VIDIOC_QUERYCAP
967 ioctl), otherwise, the driver won't compile when submitted to kernel.
969 There are several compatibility procedures already defined
970 in "compat.h" file. If needed, it is better to include it after all
971 other kernel standard headers, and before any specific header
972 for that file. Something like:
974 #include <linux/kernel.h>
975 #include <linux/module.h>
977 #include <linux/videodev2.h>
978 #include <media/v4l2-common.h>
982 #include "mydriver-header.h"
984 should be included at the files under v4l-dvb tree. This header also
985 includes linux/version.h.
987 To include testing code, #if 0 or #if 1 may be used. If this code
988 is meant to go also to kernel, a comment with the word "keep" should
995 The kernel submit scripts will remove the compatibility codes, the
996 tests for specific kernel versions and the #if 0/1 that doesn't have
999 See the file v4l/scripts/gentree.pl for a more complete description
1000 of what kind of code will be kept and what kind will be removed.
1002 e) To import contributed stuff to a developer's, a script is provided.
1003 This allows an easy import of mbox-based patch emails.
1004 This is done with (called from the root tree directory):
1006 ./mailimport <mbox file>
1008 For it to work properly, git tools need to be installed on the local
1009 machine, since git has a gitimport script that is used by mailimport.
1011 There's also a helper script to make easier to retrieve patches from
1012 other Mercurial repositories. The syntax is:
1015 Also, hg has a feature, called mqueue, that allows having several patches
1016 that can be applied/unapplied for testing. mailimport trusts on it to work,
1017 so, this extension should be enabled for mailimport script to work.
1019 3. Knowing about newer patches committed at the development repositories
1020 =====================================================================
1022 There are patchbomb scripts at linuxtv.org that will send one copy of
1023 each patch applied patch to v4l-dvb.git and v4l-dvb trees to announce
1024 when a patch is received. This announcement goes to the linuxtv-commits mailing list, hosted on linuxtv.org.
1026 The Mercurial script also currently sends a copy of the patch to:
1028 1) The patch author (as stated on the From: field in the patch comments);
1030 2) The patch committer (the "user" at hg metadata);
1032 3) All people with Signed-off-by:, Acked-by:, or CC: metadata clause
1033 in the patch's comment.
1035 If, for some reason, there's no "From:" metatag (or it is on the first
1036 line, instead of the second one), sometimes the script may fail, maybe
1037 filling patch authorship wrongly. So people should take care to properly
1038 commit patches with "From:".
1040 It is recommended that the developers who submit a pull request via Mercurial
1041 to not touch on the submission tree, until he receives the notification email,
1042 since, even after being merged at -git, the backport maintainer will need to
1045 4. Patch submission from the community
1046 ===================================
1048 Patch submission is open to all the Free Software community. The general
1049 procedure to have a patch accepted in the v4l/dvb subsystem and in the
1050 kernel is the following:
1052 a. Post your patches to the mailing list for review and test by other people:
1053 linux-media@vger.kernel.org
1055 This mailing list doesn't require subscription, although
1056 it is recommended to subscribe, expecially if you're
1057 developing V4L/DVB drivers.
1059 b. Use [PATCH] and a brief description in the email's subject.
1060 This will help the LinuxTV team to better handle it.
1062 c. Please include a brief description in the headers of your
1063 patch, like described above. Something like:
1065 This is just a sample commit comment, just for reference purposes.
1068 Signed-off-by: nowhere <nowere@noplace.org>
1070 d. Every patch shall have a Developer's Certificate of Origin and should
1071 be submitted by one of its authors. All the patch authors should sign
1074 e. People will eventually comment about the patch. In this case,
1075 please fix problems and repeat until everyone is happy ;)
1077 f. If the patch is fixing an existing maintained driver, the
1078 low-level driver maintainer will apply to his tree, and at some later
1079 time, ask the subsystem maintainer to pull it. It is a good idea to
1080 send the patch to the maintainer C/C the mailing list for him to know
1081 that you're expecting him to forward the patch.
1083 g. If it is a newer driver (not yet in one of the development trees),
1084 please send the patch to the subsystem maintainer, C/C the proper
1087 h. Prefer to submit your patches against git, especially if it contains fixes
1088 that needs to go upstream.
1090 5. Identifying regressions with Mercurial
1091 ======================================
1093 The better way for you to identify regressions with Mercurial is to
1094 use hg bisect. This is an extension provided with the current
1095 Mercurial versions. For it to work, you need to have the proper setup
1096 at an hgrc file. To test if bisect is working, you can do:
1099 If Mercurial answers with
1100 hg: unknown command 'bisect'
1102 You will need to add the following lines to your ~/.hgrc file:
1104 hgext.hbisect=/usr/lib/python2.5/site-packages/hgext/hbisect.py
1106 (assuming that hbisect.py is installed under python2.5 default dir)
1108 The first step is to initialize bisect for a newer regression testing
1109 session. This is done with:
1112 If the bisect were previously initialized, you should, instead do:
1115 Supposing that the latest kernel version have some regression, you
1116 should do something like:
1119 (This will clean any changes you had on your tree, and will update to
1122 Then, you will mark the latest version as "bad":
1125 The next step is to find one version where the your board is properly
1126 working. Supposing that review "4000" is ok, you would do:
1129 Test if the review is really ok. If so, you should mark it as good:
1132 If everything is ok, it should print something like:
1134 Testing changeset 4481:a53c7904e47d (944 changesets remaining, ~9 tests)
1135 405 files updated, 0 files merged, 8 files removed, 0 files unresolved
1137 The above line shows that Mercurial selected another revision for you
1138 to test. Redo your tests. If this version is ok, you would do:
1142 otherwise, if the version is broken, you should do:
1146 This should be repeated until you have an answer like:
1148 The first bad revision is:
1149 changeset: 4593:26d1ce012c5e
1150 user: Someone <Someone@somewhere>
1151 date: Thu Feb 31 17:52:53 2006 -0300
1152 summary: This is the broken patch that we should find
1154 If, in the middle of the process, you need to know on what revision
1155 you are, you can do something like:
1156 hg log -r `hg id|cut -d' ' -f 1`
1158 6. Identifying regressions with Git
1159 ================================
1161 A similar bisect procedure to identify broken patches exist on git, and it
1162 is used not only by LinuxTV. So, it is very important that any applied
1163 patch at the kernel don't break compilation, to avoid affecting the bisect
1166 There are several good texts explaining how to use bisect with git. Some
1167 recommended procedures can be seen at:
1169 http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#using-bisect
1170 http://www.kernel.org/pub/software/scm/git/docs/git-bisect.html
1173 7. Creating a newer driver
1174 =======================
1176 This quick HOWTO explains how to create a new driver using v4l-dvb
1179 The v4l-dvb tree have a the following basic structure:
1182 | |-- dvb <== DVB drivers documentation
1183 | `-- video4linux <== V4L drivers documentation
1186 | |-- common <== Common stuff, like IR
1187 | |-- dvb <== DVB only drivers
1188 | |-- radio <== V4L Radio only drivers
1189 | `-- video <== V4L Analog TV (plus radio and/or
1192 |-- linux <== V4L userspace API files
1193 | `-- dvb <== DVB userspace API files
1194 `-- media <== V4L internal API files
1196 When using Mercurial trees, an additional /linux prefix should be added
1202 For very simple drivers that have only one .c and one .h file, the
1203 recommended way is not to create a newer directory, but keep the
1204 driver into an existing one.
1206 Assuming that the will be V4L+DVB, the better place for it to be is under
1207 /drivers/media/video. Assuming also that the newer driver
1208 will be called as "newdevice", you need to do:
1210 a) add at /drivers/media/video/Kconfig something like:
1212 config VIDEO_NEWDEVICE
1213 tristate "newdevice driver"
1217 Support for newdevice Device
1219 Say Y if you own such a device and want to use it.
1221 b) add at /drivers/media/video/Makefile something like:
1223 obj-$(CONFIG_VIDEO_NEWDEVICE) += newdevice.o
1224 EXTRA_CFLAGS = -Idrivers/media/video
1229 In this case, a driver will be splitted into several different source
1230 codes. Ideally, a source file should have up to 1000 source code
1231 lines. After that, you should consider splitting it into smaller files.
1233 In this case, assuming that the will be V4L+DVB, and that the driver
1234 is called "newdevice", all that is needed to add the newer driver is:
1236 a) create a newer dir with your driver, for example:
1237 /drivers/media/video/newdevice
1238 b) create /drivers/media/video/newdevice/Kconfig with something
1241 config VIDEO_NEWDEVICE
1242 tristate "newdevice driver"
1246 Support for new device Device
1248 Say Y if you own such a device and want to use it.
1250 c) create /drivers/media/video/newdevice/Makefile with
1253 obj-$(CONFIG_VIDEO_NEWDEVICE) += newdevice.o
1254 EXTRA_CFLAGS = -Idrivers/media/video
1256 d) Add your driver directory at /drivers/media/Makefile:
1258 obj-$(CONFIG_VIDEO_NEWDEVICE) += newdevice/
1260 e) Add your driver directory at /drivers/media/Kconfig:
1262 source "drivers/media/video/newdevice/Kconfig"
1264 After that, you will be able to use v4l-dvb Makefile to compile your
1267 In order to test if your patch is properly compiling, you'll need to
1268 enable its compilation by using make menuconfig/make qconfig/make xconfig.
1269 After that, you can test if your patch compiles well with:
1271 make drivers/media (on git)