aboutsummaryrefslogtreecommitdiffstats
BranchCommit messageAuthorAge
archive/unc-master-3.0P-FP: fix BUG_ON releated to priority inheritanceBjoern Brandenburg13 years
archived-2013.1uncachedev: mmap memory that is not cached by CPUsGlenn Elliott12 years
archived-private-masterMerge branch 'wip-2.6.34' into old-private-masterAndrea Bastoni15 years
archived-semi-partMerge branch 'wip-semi-part' of ssh://cvs/cvs/proj/litmus/repo/litmus2010 int...Andrea Bastoni15 years
demoFurther refinementsJonathan Herman14 years
ecrts-pgm-finalMerge branch 'wip-ecrts14-pgm' of ssh://rtsrv.cs.unc.edu/home/litmus/litmus-r...Glenn Elliott12 years
ecrts14-pgm-finalMerge branch 'wip-ecrts14-pgm' of ssh://rtsrv.cs.unc.edu/home/litmus/litmus-r...Glenn Elliott12 years
gpusync-rtss12Final GPUSync implementation.Glenn Elliott12 years
gpusync/stagingRename IKGLP R2DGLP.Glenn Elliott12 years
linux-tipMerge branch 'slab/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/p...Linus Torvalds15 years
litmus2008-patch-seriesadd i386 feather-trace implementationBjoern B. Brandenburg16 years
masterPSN-EDF: use inferred_sporadic_job_release_atBjoern Brandenburg9 years
pgmmake it compileGlenn Elliott12 years
prop/litmus-signalsInfrastructure for Litmus signals.Glenn Elliott13 years
prop/robust-tie-breakFixed bug in edf_higher_prio().Glenn Elliott13 years
stagingFix tracepoint compilation errorFelipe Cerqueira13 years
test9/23/2016Namhoon Kim9 years
tracing-develTest kernel tracing events capabilitiesAndrea Bastoni16 years
v2.6.34-with-arm-patchessmsc911x: Add spinlocks around registers accessCatalin Marinas15 years
v2015.1Add ARM syscall def for get_current_budgetBjoern Brandenburg10 years
wip-2011.2-bbbLitmus core: simplify np-section protocolBjoern B. Brandenburg14 years
wip-2011.2-bbb-traceRefactor sched_trace_log_message() -> debug_trace_log_message()Andrea Bastoni14 years
wip-2012.3-gpuSOBLIV draining support for C-EDF.Glenn Elliott12 years
wip-2012.3-gpu-preportpick up last C-RM fileGlenn Elliott12 years
wip-2012.3-gpu-rtss13Fix critical bug in GPU tracker.Glenn Elliott12 years
wip-2012.3-gpu-sobliv-budget-w-ksharkProper sobliv draining and many bug fixes.Glenn Elliott12 years
wip-aedzl-finalMake it easier to compile AEDZL interfaces in liblitmus.Glenn Elliott15 years
wip-aedzl-revisedAdd sched_trace data for Apative EDZLGlenn Elliott15 years
wip-arbit-deadlineFix compilation bug.Glenn Elliott13 years
wip-aux-tasksDescription of refined aux task inheritance.Glenn Elliott13 years
wip-bbbGSN-EDF & Core: improve debug TRACE'ing for NP sectionsBjoern B. Brandenburg14 years
wip-bbb-prio-donuse correct timestampBjoern B. Brandenburg14 years
wip-better-breakImplement hash-based EDF tie-breaking.Glenn Elliott13 years
wip-binary-heapMake C-EDF work with simplified binheap_deleteGlenn Elliott13 years
wip-budgetAdded support for choices in budget policy enforcement.Glenn Elliott15 years
wip-colorSummarize schedulability with final recordJonathan Herman13 years
wip-color-jlhsched_color: Fixed two bugs causing crashing on experiment restart and a rare...Jonathan Herman13 years
wip-d10-hz1000Enable HZ=1000 on District 10Bjoern B. Brandenburg15 years
wip-default-clusteringFeature: Make default C-EDF clustering compile-time configurable.Glenn Elliott15 years
wip-dissipation-jericksoUpdate from 2.6.36 to 2.6.36.4Jeremy Erickson11 years
wip-dissipation2-jericksoUpdate 2.6.36 to 2.6.36.4Jeremy Erickson11 years
wip-ecrts14-pgmMerge branch 'wip-ecrts14-pgm' of ssh://rtsrv.cs.unc.edu/home/litmus/litmus-r...Glenn Elliott12 years
wip-edf-hsblast tested versionJonathan Herman14 years
wip-edf-osLookup table EDF-osJeremy Erickson12 years
wip-edf-tie-breakMerge branch 'wip-edf-tie-break' of ssh://rtsrv.cs.unc.edu/home/litmus/litmus...Glenn Elliott13 years
wip-edzl-critiqueUse hr_timer's active checks instead of having own flag.Glenn Elliott15 years
wip-edzl-finalImplementation of the EDZL scheduler.Glenn Elliott15 years
wip-edzl-revisedClean up comments.Glenn Elliott15 years
wip-eventsAdded support for tracing arbitrary actions.Jonathan Herman15 years
wip-extra-debugDBG: add additional tracingBjoern B. Brandenburg15 years
wip-fix-switch-jericksoAttempt to fix race condition with plugin switchingJeremy Erickson15 years
wip-fix3sched: show length of runqueue clock deactivation in /proc/sched_debugBjoern B. Brandenburg15 years
wip-fmlp-dequeueImprove FMLP queue management.Glenn Elliott14 years
wip-ft-irq-flagFeather-Trace: keep track of interrupt-related interference.Bjoern B. Brandenburg14 years
wip-gpu-cleanupEnable sched_trace log injection from userspaceGlenn Elliott13 years
wip-gpu-interruptsRemove option for threading of all softirqs.Glenn Elliott14 years
wip-gpu-rtas12Generalized GPU cost predictors + EWMA. (untested)Glenn Elliott13 years
wip-gpu-rtss12Final GPUSync implementation.Glenn Elliott13 years
wip-gpu-rtss12-srpexperimental changes to support GPUs under SRPGlenn Elliott13 years
wip-gpusync-mergeCleanup priority tracking for budget enforcement.Glenn Elliott11 years
wip-ikglpMove RSM and IKGLP imp. to own .c filesGlenn Elliott13 years
wip-k-fmlpMerge branch 'mpi-master' into wip-k-fmlpGlenn Elliott14 years
wip-kernel-coloringAdded recolor syscallNamhoon Kim7 years
wip-kernthreadsKludge work-queue processing into klitirqd.Glenn Elliott15 years
wip-klmirqd-to-auxAllow klmirqd threads to be given names.Glenn Elliott13 years
wip-ksharkMerge branch 'mpi-staging' into wip-ksharkJonathan Herman13 years
wip-litmus-3.2Merge commit 'v3.2' into litmus-stagingAndrea Bastoni13 years
wip-litmus2011.2Cleanup: Coding conformance for affinity stuff.Glenn Elliott14 years
wip-litmus3.0-2011.2Feather-Trace: keep track of interrupt-related interference.Bjoern B. Brandenburg14 years
wip-master-2.6.33-rtAvoid deadlock when switching task policy to BACKGROUND (ugly)Andrea Bastoni15 years
wip-mcRemoved ARM-specific hacks which disabled less common mixed-criticality featu...Jonathan Herman12 years
wip-mc-bipasaMC-EDF addedbipasa chattopadhyay13 years
wip-mc-jericksoSplit C/D queuesJeremy Erickson15 years
wip-mc2-cache-slackManually patched mc^2 related codeMing Yang10 years
wip-mcrit-maccosmeticMac Mollison15 years
wip-merge-3.0Prevent Linux to send IPI and queue tasks on remote CPUs.Andrea Bastoni14 years
wip-merge-v3.0Prevent Linux to send IPI and queue tasks on remote CPUs.Andrea Bastoni14 years
wip-migration-affinityNULL affinity dereference in C-EDF.Glenn Elliott14 years
wip-mmap-uncacheshare branch with othersGlenn Elliott13 years
wip-modechangeRTSS 2017 submissionNamhoon Kim8 years
wip-nested-lockingAppears to be working.Bryan Ward12 years
wip-omlp-gedfFirst implementation of G-OMLP.Glenn Elliott15 years
wip-paiSome cleanup of PAIGlenn Elliott14 years
wip-percore-lib9/21/2016Namhoon Kim9 years
wip-performanceCONFIG_DONT_PREEMPT_ON_TIE: Don't preeempt a scheduled task on priority tie.Glenn Elliott14 years
wip-pgmAdd PGM support to C-FLGlenn Elliott12 years
wip-pgm-splitFirst draft of C-FL-splitNamhoon Kim12 years
wip-pm-ovdAdd preemption-and-migration overhead tracing supportAndrea Bastoni15 years
wip-prio-inhP-EDF updated to use the generic pi framework.Glenn Elliott15 years
wip-prioq-dglBUG FIX: Support DGLs with PRIOQ_MUTEXGlenn Elliott13 years
wip-refactored-gedfGeneralizd architecture for GEDF-style scheduelrs to reduce code redundancy.Glenn Elliott15 years
wip-release-master-fixbugfix: release master CPU must signal task was pickedBjoern B. Brandenburg14 years
wip-robust-tie-breakEDF priority tie-breaks.Glenn Elliott13 years
wip-rt-ksharkMove task time accounting into the complete_job method.Jonathan Herman13 years
wip-rtas12-pgmScheduling of PGM jobs.Glenn Elliott13 years
wip-semi-partFix compile error with newer GCCJeremy Erickson12 years
wip-semi-part-edfos-jericksoUse initial CPU set by clientJeremy Erickson12 years
wip-shared-libTODO: Fix condition checks in replicate_page_move_mapping()Namhoon Kim9 years
wip-shared-lib2RTAS 2017 Submission ver.Namhoon Kim9 years
wip-shared-memInitial commit for shared libraryNamhoon Kim9 years
wip-splitting-jericksoFix release behaviorJeremy Erickson13 years
wip-splitting-omlp-jericksoBjoern's Dissertation Code with Priority DonationJeremy Erickson13 years
wip-stage-binheapAn efficient binary heap implementation.Glenn Elliott13 years
wip-sun-portDynamic memory allocation and clean exit for FeatherTraceChristopher Kenna15 years
wip-timer-tracebugfix: C-EDF, clear scheduled field of the correct CPU upon task_exitAndrea Bastoni15 years
wip-tracepointsAdd kernel-style events for sched_trace_XXX() functionsAndrea Bastoni14 years
 
TagDownloadAuthorAge
2015.1commit 8e51b37822...Bjoern Brandenburg10 years
2013.1commit bcaacec1ca...Glenn Elliott12 years
2012.3commit c158b5fbe4...Jonathan Herman13 years
2012.2commit b53c479a0f...Glenn Elliott13 years
2012.1commit 83b11ea1c6...Bjoern B. Brandenburg14 years
rtas12-mc-beta-expcommit 8e236ee20f...Christopher Kenna14 years
2011.1commit d11808b5c6...Christopher Kenna15 years
v2.6.37-rc4commit e8a7e48bb2...Linus Torvalds15 years
v2.6.37-rc3commit 3561d43fd2...Linus Torvalds15 years
v2.6.37-rc2commit e53beacd23...Linus Torvalds15 years
v2.6.37-rc1commit c8ddb2713c...Linus Torvalds15 years
v2.6.36commit f6f94e2ab1...Linus Torvalds15 years
2010.2commit 5c5456402d...Bjoern B. Brandenburg15 years
v2.6.36-rc8commit cd07202cc8...Linus Torvalds15 years
v2.6.36-rc7commit cb655d0f3d...Linus Torvalds15 years
v2.6.36-rc6commit 899611ee7d...Linus Torvalds15 years
v2.6.36-rc5commit b30a3f6257...Linus Torvalds15 years
v2.6.36-rc4commit 49553c2ef8...Linus Torvalds15 years
v2.6.36-rc3commit 2bfc96a127...Linus Torvalds15 years
v2.6.36-rc2commit 76be97c1fc...Linus Torvalds15 years
v2.6.36-rc1commit da5cabf80e...Linus Torvalds15 years
v2.6.35commit 9fe6206f40...Linus Torvalds15 years
v2.6.35-rc6commit b37fa16e78...Linus Torvalds15 years
v2.6.35-rc5commit 1c5474a65b...Linus Torvalds15 years
v2.6.35-rc4commit 815c4163b6...Linus Torvalds15 years
v2.6.35-rc3commit 7e27d6e778...Linus Torvalds15 years
v2.6.35-rc2commit e44a21b726...Linus Torvalds15 years
v2.6.35-rc1commit 67a3e12b05...Linus Torvalds15 years
2010.1commit 7c1ff4c544...Andrea Bastoni15 years
v2.6.34commit e40152ee1e...Linus Torvalds15 years
v2.6.33.4commit 4640b4e7d9...Greg Kroah-Hartman15 years
v2.6.34-rc7commit b57f95a382...Linus Torvalds15 years
v2.6.34-rc6commit 66f41d4c5c...Linus Torvalds15 years
v2.6.33.3commit 3e7ad8ed97...Greg Kroah-Hartman15 years
v2.6.34-rc5commit 01bf0b6457...Linus Torvalds15 years
v2.6.34-rc4commit 0d0fb0f9c5...Linus Torvalds15 years
v2.6.33.2commit 19f00f070c...Greg Kroah-Hartman15 years
v2.6.34-rc3commit 2eaa9cfdf3...Linus Torvalds15 years
v2.6.34-rc2commit 220bf991b0...Linus Torvalds15 years
v2.6.33.1commit dbdafe5ccf...Greg Kroah-Hartman16 years
v2.6.34-rc1commit 57d54889cd...Linus Torvalds16 years
v2.6.33commit 60b341b778...Linus Torvalds16 years
v2.6.33-rc8commit 724e6d3fe8...Linus Torvalds16 years
v2.6.33-rc7commit 29275254ca...Linus Torvalds16 years
v2.6.33-rc6commit abe94c756c...Linus Torvalds16 years
v2.6.33-rc5commit 92dcffb916...Linus Torvalds16 years
v2.6.33-rc4commit 7284ce6c9f...Linus Torvalds16 years
v2.6.33-rc3commit 74d2e4f8d7...Linus Torvalds16 years
v2.6.33-rc2commit 6b7b284958...Linus Torvalds16 years
v2.6.33-rc1commit 55639353a0...Linus Torvalds16 years
v2.6.32commit 22763c5cf3...Linus Torvalds16 years
v2.6.32-rc8commit 648f4e3e50...Linus Torvalds16 years
v2.6.32-rc7commit 156171c71a...Linus Torvalds16 years
v2.6.32-rc6commit b419148e56...Linus Torvalds16 years
v2.6.32-rc5commit 012abeea66...Linus Torvalds16 years
v2.6.32-rc4commit 161291396e...Linus Torvalds16 years
v2.6.32-rc3commit 374576a8b6...Linus Torvalds16 years
v2.6.32-rc1commit 17d857be64...Linus Torvalds16 years
v2.6.32-rc2commit 17d857be64...Linus Torvalds16 years
v2.6.31commit 74fca6a428...Linus Torvalds16 years
v2.6.31-rc9commit e07cccf404...Linus Torvalds16 years
v2.6.31-rc8commit 326ba5010a...Linus Torvalds16 years
v2.6.31-rc7commit 422bef879e...Linus Torvalds16 years
v2.6.31-rc6commit 64f1607ffb...Linus Torvalds16 years
v2.6.31-rc5commit ed680c4ad4...Linus Torvalds16 years
v2.6.31-rc4commit 4be3bd7849...Linus Torvalds16 years
v2.6.31-rc3commit 6847e154e3...Linus Torvalds16 years
v2.6.31-rc2commit 8e4a718ff3...Linus Torvalds16 years
v2.6.31-rc1commit 28d0325ce6...Linus Torvalds16 years
v2.6.30commit 07a2039b8e...Linus Torvalds16 years
v2.6.30-rc8commit 9fa7eb283c...Linus Torvalds16 years
v2.6.30-rc7commit 59a3759d0f...Linus Torvalds16 years
v2.6.30-rc6commit 1406de8e11...Linus Torvalds16 years
v2.6.30-rc5commit 091bf7624d...Linus Torvalds16 years
v2.6.30-rc4commit 091438dd56...Linus Torvalds16 years
v2.6.30-rc3commit 0910697403...Linus Torvalds16 years
v2.6.30-rc2commit 0882e8dd3a...Linus Torvalds16 years
v2.6.30-rc1commit 577c9c456f...Linus Torvalds16 years
v2.6.29commit 8e0ee43bc2...Linus Torvalds16 years
v2.6.29-rc8commit 041b62374c...Linus Torvalds17 years
v2.6.29-rc7commit fec6c6fec3...Linus Torvalds17 years
v2.6.29-rc6commit 20f4d6c3a2...Linus Torvalds17 years
v2.6.29-rc5commit d2f8d7ee1a...Linus Torvalds17 years
v2.6.29-rc4commit 8e4921515c...Linus Torvalds17 years
v2.6.29-rc3commit 18e352e4a7...Linus Torvalds17 years
v2.6.29-rc2commit 1de9e8e70f...Linus Torvalds17 years
v2.6.29-rc1commit c59765042f...Linus Torvalds17 years
v2.6.28commit 4a6908a3a0...Linus Torvalds17 years
v2.6.28-rc9commit 929096fe9f...Linus Torvalds17 years
v2.6.28-rc8commit 8b1fae4e42...Linus Torvalds17 years
v2.6.28-rc7commit 061e41fdb5...Linus Torvalds17 years
v2.6.28-rc6commit 13d428afc0...Linus Torvalds17 years
v2.6.28-rc5commit 9bf1a2445f...Linus Torvalds17 years
v2.6.28-rc4commit f7160c7573...Linus Torvalds17 years
v2.6.28-rc3commit 45beca08dd...Linus Torvalds17 years
v2.6.28-rc2commit 0173a3265b...Linus Torvalds17 years
v2.6.28-rc1commit 57f8f7b60d...Linus Torvalds17 years
v2.6.27commit 3fa8749e58...Linus Torvalds17 years
v2.6.27-rc9commit 4330ed8ed4...Linus Torvalds17 years
v2.6.27-rc8commit 94aca1dac6...Linus Torvalds17 years
v2.6.27-rc7commit 72d31053f6...Linus Torvalds17 years
v2.6.27-rc6commit adee14b2e1...Linus Torvalds17 years
v2.6.27-rc5commit 24342c34a0...Linus Torvalds17 years
v2.6.27-rc4commit 6a55617ed5...Linus Torvalds17 years
v2.6.27-rc3commit 30a2f3c60a...Linus Torvalds17 years
v2.6.27-rc2commit 0967d61ea0...Linus Torvalds17 years
v2.6.27-rc1commit 6e86841d05...Linus Torvalds17 years
v2.6.26commit bce7f793da...Linus Torvalds17 years
v2.6.26-rc9commit b7279469d6...Linus Torvalds17 years
v2.6.26-rc8commit 543cf4cb3f...Linus Torvalds17 years
v2.6.26-rc7commit d70ac829b7...Linus Torvalds17 years
v2.6.26-rc6commit 5dd34572ad...Linus Torvalds17 years
v2.6.26-rc5commit 53c8ba9540...Linus Torvalds17 years
v2.6.26-rc4commit e490517a03...Linus Torvalds17 years
v2.6.26-rc3commit b8291ad07a...Linus Torvalds17 years
v2.6.26-rc2commit 492c2e476e...Linus Torvalds17 years
v2.6.26-rc1commit 2ddcca36c8...Linus Torvalds17 years
v2.6.25commit 4b119e21d0...Linus Torvalds17 years
v2.6.25-rc9commit 120dd64cac...Linus Torvalds17 years
v2.6.25-rc8commit 0e81a8ae37...Linus Torvalds17 years
v2.6.25-rc7commit 05dda977f2...Linus Torvalds17 years
v2.6.25-rc6commit a978b30af3...Linus Torvalds17 years
v2.6.25-rc5commit cdeeeae056...Linus Torvalds18 years
v2.6.25-rc4commit 29e8c3c304...Linus Torvalds18 years
v2.6.25-rc3commit bfa274e243...Linus Torvalds18 years
v2.6.25-rc2commit 101142c37b...Linus Torvalds18 years
v2.6.25-rc1commit 19af35546d...Linus Torvalds18 years
v2.6.24commit 49914084e7...Linus Torvalds18 years
v2.6.24-rc8commit cbd9c88369...Linus Torvalds18 years
v2.6.24-rc7commit 3ce5445046...Linus Torvalds18 years
v2.6.24-rc6commit ea67db4cdb...Linus Torvalds18 years
v2.6.24-rc5commit 82d29bf6dc...Linus Torvalds18 years
v2.6.24-rc4commit 09b56adc98...Linus Torvalds18 years
v2.6.24-rc3commit d9f8bcbf67...Linus Torvalds18 years
v2.6.24-rc2commit dbeeb816e8...Linus Torvalds18 years
v2.6.24-rc1commit c9927c2bf4...Linus Torvalds18 years
v2.6.23commit bbf25010f1...Linus Torvalds18 years
v2.6.23-rc9commit 3146b39c18...Linus Torvalds18 years
v2.6.23-rc8commit 4942de4a0e...Linus Torvalds18 years
v2.6.23-rc7commit 81cfe79b9c...Linus Torvalds18 years
v2.6.23-rc6commit 0d4cbb5e7f...Linus Torvalds18 years
v2.6.23-rc5commit 40ffbfad6b...Linus Torvalds18 years
v2.6.23-rc4commit b07d68b5ca...Linus Torvalds18 years
v2.6.23-rc3commit 39d3520c92...Linus Torvalds18 years
v2.6.23-rc2commit d4ac2477fa...Linus Torvalds18 years
v2.6.23-rc1commit f695baf2df...Linus Torvalds18 years
v2.6.22commit 7dcca30a32...Linus Torvalds18 years
v2.6.22-rc7commit a38d6181ff...Linus Torvalds18 years
v2.6.22-rc6commit 189548642c...Linus Torvalds18 years
v2.6.22-rc5commit 188e1f81ba...Linus Torvalds18 years
v2.6.22-rc4commit 5ecd3100e6...Linus Torvalds18 years
v2.6.22-rc3commit c420bc9f09...Linus Torvalds18 years
v2.6.22-rc2commit 55b637c6a0...Linus Torvalds18 years
v2.6.22-rc1commit 39403865d2...Linus Torvalds18 years
v2.6.21commit de46c33745...Linus Torvalds18 years
v2.6.21-rc7commit 94a05509a9...Linus Torvalds18 years
v2.6.21-rc6commit a21bd69e15...Linus Torvalds18 years
v2.6.21-rc5commit e0f2e3a06b...Linus Torvalds18 years
v2.6.21-rc4commit db98e0b434...Linus Torvalds19 years
v2.6.21-rc3commit 08e15e81a4...Linus Torvalds19 years
v2.6.21-rc2commit 606135a308...Linus Torvalds19 years
v2.6.21-rc1commit c8f71b01a5...Linus Torvalds19 years
v2.6.20commit 62d0cfcb27...Linus Torvalds19 years
v2.6.20-rc7commit f56df2f4db...Linus Torvalds19 years
v2.6.20-rc6commit 99abfeafb5...Linus Torvalds19 years
v2.6.20-rc5commit a8b3485287...Linus Torvalds19 years
v2.6.20-rc4commit bf81b46482...Linus Torvalds19 years
v2.6.20-rc3commit 669df1b478...Linus Torvalds19 years
v2.6.20-rc2commit 3bf8ba38f3...Linus Torvalds19 years
v2.6.20-rc1commit cc016448b0...Linus Torvalds19 years
v2.6.19commit 0215ffb08c...Linus Torvalds19 years
v2.6.19-rc6commit 44597f65f6...Linus Torvalds19 years
v2.6.19-rc5commit 80c2188127...Linus Torvalds19 years
v2.6.19-rc4commit ae99a78af3...Linus Torvalds19 years
v2.6.19-rc3commit 7059abedd2...Linus Torvalds19 years
v2.6.19-rc2commit b4bd8c6643...Linus Torvalds19 years
v2.6.19-rc1commit d223a60106...Linus Torvalds19 years
v2.6.18commit e478bec0ba...Linus Torvalds19 years
v2.6.18-rc7commit 95064a75eb...Linus Torvalds19 years
v2.6.18-rc6commit c336923b66...Linus Torvalds19 years
v2.6.18-rc5commit 60d4684068...Linus Torvalds19 years
v2.6.18-rc4commit 9f737633e6...Linus Torvalds19 years
v2.6.18-rc3commit b6ff50833a...Linus Torvalds19 years
v2.6.18-rc2commit 82d6897fef...Linus Torvalds19 years
v2.6.18-rc1commit 120bda20c6...Linus Torvalds19 years
v2.6.17commit 427abfa28a...Linus Torvalds19 years
v2.6.17-rc6commit 1def630a6a...Linus Torvalds19 years
v2.6.17-rc5commit a8bd60705a...Linus Torvalds19 years
v2.6.17-rc4commit d8c3291c73...Linus Torvalds19 years
v2.6.17-rc3commit 2be4d50295...Linus Torvalds19 years
v2.6.17-rc2commit 8bbde0e6d5...Linus Torvalds19 years
v2.6.17-rc1commit 6246b6128b...Linus Torvalds19 years
v2.6.16commit 7705a8792b...Linus Torvalds19 years
v2.6.16-rc6commit 535744878e...Linus Torvalds20 years
v2.6.16-rc5commit b9a33cebac...Linus Torvalds20 years
v2.6.16-rc4commit bd71c2b174...Linus Torvalds20 years
v2.6.16-rc3commit e9bb4c9929...Linus Torvalds20 years
v2.6.16-rc2commit 826eeb53a6...Linus Torvalds20 years
v2.6.16-rc1commit 2664b25051...Linus Torvalds20 years
v2.6.15commit 88026842b0...Linus Torvalds20 years
v2.6.15-rc7commit f89f5948fc...Linus Torvalds20 years
v2.6.15-rc6commit df7addbb45...Linus Torvalds20 years
v2.6.15-rc5commit 436b0f76f2...Linus Torvalds20 years
v2.6.15-rc4commit 5666c0947e...Linus Torvalds20 years
v2.6.15-rc3commit 624f54be20...Linus Torvalds20 years
v2.6.15-rc2commit 3bedff1d73...Linus Torvalds20 years
v2.6.15-rc1commit cd52d1ee9a...Linus Torvalds20 years
v2.6.14commit 741b2252a5...Linus Torvalds20 years
v2.6.14-rc5commit 93918e9afc...Linus Torvalds20 years
v2.6.14-rc4commit 907a426179...Linus Torvalds20 years
v2.6.14-rc3commit 1c9426e8a5...Linus Torvalds20 years
v2.6.14-rc2commit 676d55ae30...Linus Torvalds20 years
v2.6.14-rc1commit 2f4ba45a75...Linus Torvalds20 years
v2.6.13commit 02b3e4e2d7...Linus Torvalds20 years
v2.6.13-rc7commit 0572e3da3f...Linus Torvalds20 years
v2.6.13-rc6commit 6fc32179de...Linus Torvalds20 years
v2.6.13-rc5commit 9a351e30d7...Linus Torvalds20 years
v2.6.13-rc4commit 6395352334...Linus Torvalds20 years
v2.6.11tree c39ae07f39...
v2.6.11-treetree c39ae07f39...
v2.6.12commit 9ee1c939d1...
v2.6.12-rc2commit 1da177e4c3...
v2.6.12-rc3commit a2755a80f4...
v2.6.12-rc4commit 88d7bd8cb9...
v2.6.12-rc5commit 2a24ab628a...
v2.6.12-rc6commit 7cef5677ef...
v2.6.13-rc1commit 4c91aedb75...
v2.6.13-rc2commit a18bcb7450...
v2.6.13-rc3commit c32511e271...
river. * * Corey Minyard (minyard@wf-rch.cirr.com) * * Colossians 3:17 * * See Documentation/cdrom/cdu31a for additional details about this driver. * * The Sony interface device driver handles Sony interface CDROM * drives and provides a complete block-level interface as well as an * ioctl() interface compatible with the Sun (as specified in * include/linux/cdrom.h). With this interface, CDROMs can be * accessed and standard audio CDs can be played back normally. * * WARNING - All autoprobes have been removed from the driver. * You MUST configure the CDU31A via a LILO config * at boot time or in lilo.conf. I have the * following in my lilo.conf: * * append="cdu31a=0x1f88,0,PAS" * * The first number is the I/O base address of the * card. The second is the interrupt (0 means none). * The third should be "PAS" if on a Pro-Audio * spectrum, or nothing if on something else. * * This interface is (unfortunately) a polled interface. This is * because most Sony interfaces are set up with DMA and interrupts * disables. Some (like mine) do not even have the capability to * handle interrupts or DMA. For this reason you will see a lot of * the following: * * retry_count = jiffies+ SONY_JIFFIES_TIMEOUT; * while (time_before(jiffies, retry_count) && (! <some condition to wait for)) * { * while (handle_sony_cd_attention()) * ; * * sony_sleep(); * } * if (the condition not met) * { * return an error; * } * * This ugly hack waits for something to happen, sleeping a little * between every try. it also handles attentions, which are * asynchronous events from the drive informing the driver that a disk * has been inserted, removed, etc. * * NEWS FLASH - The driver now supports interrupts but they are * turned off by default. Use of interrupts is highly encouraged, it * cuts CPU usage down to a reasonable level. I had DMA in for a while * but PC DMA is just too slow. Better to just insb() it. * * One thing about these drives: They talk in MSF (Minute Second Frame) format. * There are 75 frames a second, 60 seconds a minute, and up to 75 minutes on a * disk. The funny thing is that these are sent to the drive in BCD, but the * interface wants to see them in decimal. A lot of conversion goes on. * * DRIVER SPECIAL FEATURES * ----------------------- * * This section describes features beyond the normal audio and CD-ROM * functions of the drive. * * XA compatibility * * The driver should support XA disks for both the CDU31A and CDU33A. * It does this transparently, the using program doesn't need to set it. * * Multi-Session * * A multi-session disk looks just like a normal disk to the user. * Just mount one normally, and all the data should be there. * A special thanks to Koen for help with this! * * Raw sector I/O * * Using the CDROMREADAUDIO it is possible to read raw audio and data * tracks. Both operations return 2352 bytes per sector. On the data * tracks, the first 12 bytes is not returned by the drive and the value * of that data is indeterminate. * * * Copyright (C) 1993 Corey Minyard * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * TODO: * CDs with form1 and form2 sectors cause problems * with current read-ahead strategy. * * Credits: * Heiko Eissfeldt <heiko@colossus.escape.de> * For finding abug in the return of the track numbers. * TOC processing redone for proper multisession support. * * * It probably a little late to be adding a history, but I guess I * will start. * * 10/24/95 - Added support for disabling the eject button when the * drive is open. Note that there is a small problem * still here, if the eject button is pushed while the * drive light is flashing, the drive will return a bad * status and be reset. It recovers, though. * * 03/07/97 - Fixed a problem with timers. * * * 18 Spetember 1997 -- Ported to Uniform CD-ROM driver by * Heiko Eissfeldt <heiko@colossus.escape.de> with additional * changes by Erik Andersen <andersee@debian.org> * * 24 January 1998 -- Removed the scd_disc_status() function, which was now * just dead code left over from the port. * Erik Andersen <andersee@debian.org> * * 16 July 1998 -- Drive donated to Erik Andersen by John Kodis * <kodis@jagunet.com>. Work begun on fixing driver to * work under 2.1.X. Added temporary extra printks * which seem to slow it down enough to work. * * 9 November 1999 -- Make kernel-parameter implementation work with 2.3.x * Removed init_module & cleanup_module in favor of * module_init & module_exit. * Torben Mathiasen <tmm@image.dk> * * 22 October 2004 -- Make the driver work in 2.6.X * Added workaround to fix hard lockups on eject * Fixed door locking problem after mounting empty drive * Set double-speed drives to double speed by default * Removed all readahead things - not needed anymore * Ondrej Zary <rainbow@rainbow-software.org> */ #define DEBUG 1 #include <linux/major.h> #include <linux/module.h> #include <linux/errno.h> #include <linux/signal.h> #include <linux/sched.h> #include <linux/timer.h> #include <linux/fs.h> #include <linux/kernel.h> #include <linux/hdreg.h> #include <linux/genhd.h> #include <linux/ioport.h> #include <linux/string.h> #include <linux/slab.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/cdrom.h> #include <asm/system.h> #include <asm/io.h> #include <asm/uaccess.h> #include <asm/dma.h> #include "cdu31a.h" #define MAJOR_NR CDU31A_CDROM_MAJOR #include <linux/blkdev.h> #define CDU31A_MAX_CONSECUTIVE_ATTENTIONS 10 #define PFX "CDU31A: " /* ** Edit the following data to change interrupts, DMA channels, etc. ** Default is polled and no DMA. DMA is not recommended for double-speed ** drives. */ static struct { unsigned short base; /* I/O Base Address */ short int_num; /* Interrupt Number (-1 means scan for it, 0 means don't use) */ } cdu31a_addresses[] __initdata = { {0} }; static int handle_sony_cd_attention(void); static int read_subcode(void); static void sony_get_toc(void); static int scd_spinup(void); /*static int scd_open(struct inode *inode, struct file *filp);*/ static int scd_open(struct cdrom_device_info *, int); static void do_sony_cd_cmd(unsigned char cmd, unsigned char *params, unsigned int num_params, unsigned char *result_buffer, unsigned int *result_size); static void size_to_buf(unsigned int size, unsigned char *buf); /* Parameters for the read-ahead. */ static unsigned int sony_next_block; /* Next 512 byte block offset */ static unsigned int sony_blocks_left = 0; /* Number of 512 byte blocks left in the current read command. */ /* The base I/O address of the Sony Interface. This is a variable (not a #define) so it can be easily changed via some future ioctl() */ static unsigned int cdu31a_port = 0; module_param(cdu31a_port, uint, 0); /* * The following are I/O addresses of the various registers for the drive. The * comment for the base address also applies here. */ static volatile unsigned short sony_cd_cmd_reg; static volatile unsigned short sony_cd_param_reg; static volatile unsigned short sony_cd_write_reg; static volatile unsigned short sony_cd_control_reg; static volatile unsigned short sony_cd_status_reg; static volatile unsigned short sony_cd_result_reg; static volatile unsigned short sony_cd_read_reg; static volatile unsigned short sony_cd_fifost_reg; static struct request_queue *cdu31a_queue; static DEFINE_SPINLOCK(cdu31a_lock); /* queue lock */ static int sony_spun_up = 0; /* Has the drive been spun up? */ static int sony_speed = 0; /* Last wanted speed */ static int sony_xa_mode = 0; /* Is an XA disk in the drive and the drive a CDU31A? */ static int sony_raw_data_mode = 1; /* 1 if data tracks, 0 if audio. For raw data reads. */ static unsigned int sony_usage = 0; /* How many processes have the drive open. */ static int sony_pas_init = 0; /* Initialize the Pro-Audio Spectrum card? */ static struct s_sony_session_toc single_toc; /* Holds the table of contents. */ static struct s_all_sessions_toc sony_toc; /* entries gathered from all sessions */ static int sony_toc_read = 0; /* Has the TOC been read for the drive? */ static struct s_sony_subcode last_sony_subcode; /* Points to the last subcode address read */ static DECLARE_MUTEX(sony_sem); /* Semaphore for drive hardware access */ static int is_double_speed = 0; /* does the drive support double speed ? */ static int is_auto_eject = 1; /* Door has been locked? 1=No/0=Yes */ /* * The audio status uses the values from read subchannel data as specified * in include/linux/cdrom.h. */ static volatile int sony_audio_status = CDROM_AUDIO_NO_STATUS; /* * The following are a hack for pausing and resuming audio play. The drive * does not work as I would expect it, if you stop it then start it again, * the drive seeks back to the beginning and starts over. This holds the * position during a pause so a resume can restart it. It uses the * audio status variable above to tell if it is paused. */ static unsigned volatile char cur_pos_msf[3] = { 0, 0, 0 }; static unsigned volatile char final_pos_msf[3] = { 0, 0, 0 }; /* What IRQ is the drive using? 0 if none. */ static int cdu31a_irq = 0; module_param(cdu31a_irq, int, 0); /* The interrupt handler will wake this queue up when it gets an interrupts. */ static DECLARE_WAIT_QUEUE_HEAD(cdu31a_irq_wait); static int irq_flag = 0; static int curr_control_reg = 0; /* Current value of the control register */ /* A disk changed variable. When a disk change is detected, it will all be set to TRUE. As the upper layers ask for disk_changed status it will be cleared. */ static char disk_changed; /* This was readahead_buffer once... Now it's used only for audio reads */ static char audio_buffer[CD_FRAMESIZE_RAW]; /* Used to time a short period to abort an operation after the drive has been idle for a while. This keeps the light on the drive from flashing for very long. */ static struct timer_list cdu31a_abort_timer; /* Marks if the timeout has started an abort read. This is used on entry to the drive to tell the code to read out the status from the abort read. */ static int abort_read_started = 0; /* * Uniform cdrom interface function * report back, if disc has changed from time of last request. */ static int scd_media_changed(struct cdrom_device_info *cdi, int disc_nr) { int retval; retval = disk_changed; disk_changed = 0; return retval; } /* * Uniform cdrom interface function * report back, if drive is ready */ static int scd_drive_status(struct cdrom_device_info *cdi, int slot_nr) { if (CDSL_CURRENT != slot_nr) /* we have no changer support */ return -EINVAL; if (sony_spun_up) return CDS_DISC_OK; if (down_interruptible(&sony_sem)) return -ERESTARTSYS; if (scd_spinup() == 0) sony_spun_up = 1; up(&sony_sem); return sony_spun_up ? CDS_DISC_OK : CDS_DRIVE_NOT_READY; } static inline void enable_interrupts(void) { curr_control_reg |= (SONY_ATTN_INT_EN_BIT | SONY_RES_RDY_INT_EN_BIT | SONY_DATA_RDY_INT_EN_BIT); outb(curr_control_reg, sony_cd_control_reg); } static inline void disable_interrupts(void) { curr_control_reg &= ~(SONY_ATTN_INT_EN_BIT | SONY_RES_RDY_INT_EN_BIT | SONY_DATA_RDY_INT_EN_BIT); outb(curr_control_reg, sony_cd_control_reg); } /* * Wait a little while (used for polling the drive). If in initialization, * setting a timeout doesn't work, so just loop for a while. */ static inline void sony_sleep(void) { if (cdu31a_irq <= 0) { yield(); } else { /* Interrupt driven */ DEFINE_WAIT(w); int first = 1; while (1) { prepare_to_wait(&cdu31a_irq_wait, &w, TASK_INTERRUPTIBLE); if (first) { enable_interrupts(); first = 0; } if (irq_flag != 0) break; if (!signal_pending(current)) { schedule(); continue; } else disable_interrupts(); break; } finish_wait(&cdu31a_irq_wait, &w); irq_flag = 0; } } /* * The following are convenience routine to read various status and set * various conditions in the drive. */ static inline int is_attention(void) { return (inb(sony_cd_status_reg) & SONY_ATTN_BIT) != 0; } static inline int is_busy(void) { return (inb(sony_cd_status_reg) & SONY_BUSY_BIT) != 0; } static inline int is_data_ready(void) { return (inb(sony_cd_status_reg) & SONY_DATA_RDY_BIT) != 0; } static inline int is_data_requested(void) { return (inb(sony_cd_status_reg) & SONY_DATA_REQUEST_BIT) != 0; } static inline int is_result_ready(void) { return (inb(sony_cd_status_reg) & SONY_RES_RDY_BIT) != 0; } static inline int is_param_write_rdy(void) { return (inb(sony_cd_fifost_reg) & SONY_PARAM_WRITE_RDY_BIT) != 0; } static inline int is_result_reg_not_empty(void) { return (inb(sony_cd_fifost_reg) & SONY_RES_REG_NOT_EMP_BIT) != 0; } static inline void reset_drive(void) { curr_control_reg = 0; sony_toc_read = 0; outb(SONY_DRIVE_RESET_BIT, sony_cd_control_reg); } /* * Uniform cdrom interface function * reset drive and return when it is ready */ static int scd_reset(struct cdrom_device_info *cdi) { unsigned long retry_count; if (down_interruptible(&sony_sem)) return -ERESTARTSYS; reset_drive(); retry_count = jiffies + SONY_RESET_TIMEOUT; while (time_before(jiffies, retry_count) && (!is_attention())) { sony_sleep(); } up(&sony_sem); return 0; } static inline void clear_attention(void) { outb(curr_control_reg | SONY_ATTN_CLR_BIT, sony_cd_control_reg); } static inline void clear_result_ready(void) { outb(curr_control_reg | SONY_RES_RDY_CLR_BIT, sony_cd_control_reg); } static inline void clear_data_ready(void) { outb(curr_control_reg | SONY_DATA_RDY_CLR_BIT, sony_cd_control_reg); } static inline void clear_param_reg(void) { outb(curr_control_reg | SONY_PARAM_CLR_BIT, sony_cd_control_reg); } static inline unsigned char read_status_register(void) { return inb(sony_cd_status_reg); } static inline unsigned char read_result_register(void) { return inb(sony_cd_result_reg); } static inline unsigned char read_data_register(void) { return inb(sony_cd_read_reg); } static inline void write_param(unsigned char param) { outb(param, sony_cd_param_reg); } static inline void write_cmd(unsigned char cmd) { outb(curr_control_reg | SONY_RES_RDY_INT_EN_BIT, sony_cd_control_reg); outb(cmd, sony_cd_cmd_reg); } static irqreturn_t cdu31a_interrupt(int irq, void *dev_id) { unsigned char val; if (abort_read_started) { /* We might be waiting for an abort to finish. Don't disable interrupts yet, though, because we handle this one here. */ /* Clear out the result registers. */ while (is_result_reg_not_empty()) { val = read_result_register(); } clear_data_ready(); clear_result_ready(); /* Clear out the data */ while (is_data_requested()) { val = read_data_register(); } abort_read_started = 0; /* If something was waiting, wake it up now. */ if (waitqueue_active(&cdu31a_irq_wait)) { disable_interrupts(); irq_flag = 1; wake_up_interruptible(&cdu31a_irq_wait); } } else if (waitqueue_active(&cdu31a_irq_wait)) { disable_interrupts(); irq_flag = 1; wake_up_interruptible(&cdu31a_irq_wait); } else { disable_interrupts(); printk(KERN_NOTICE PFX "Got an interrupt but nothing was waiting\n"); } return IRQ_HANDLED; } /* * give more verbose error messages */ static unsigned char *translate_error(unsigned char err_code) { static unsigned char errbuf[80]; switch (err_code) { case 0x10: return "illegal command "; case 0x11: return "illegal parameter "; case 0x20: return "not loaded "; case 0x21: return "no disc "; case 0x22: return "not spinning "; case 0x23: return "spinning "; case 0x25: return "spindle servo "; case 0x26: return "focus servo "; case 0x29: return "eject mechanism "; case 0x2a: return "audio playing "; case 0x2c: return "emergency eject "; case 0x30: return "focus "; case 0x31: return "frame sync "; case 0x32: return "subcode address "; case 0x33: return "block sync "; case 0x34: return "header address "; case 0x40: return "illegal track read "; case 0x41: return "mode 0 read "; case 0x42: return "illegal mode read "; case 0x43: return "illegal block size read "; case 0x44: return "mode read "; case 0x45: return "form read "; case 0x46: return "leadout read "; case 0x47: return "buffer overrun "; case 0x53: return "unrecoverable CIRC "; case 0x57: return "unrecoverable LECC "; case 0x60: return "no TOC "; case 0x61: return "invalid subcode data "; case 0x63: return "focus on TOC read "; case 0x64: return "frame sync on TOC read "; case 0x65: return "TOC data "; case 0x70: return "hardware failure "; case 0x91: return "leadin "; case 0x92: return "leadout "; case 0x93: return "data track "; } sprintf(errbuf, "unknown 0x%02x ", err_code); return errbuf; } /* * Set the drive parameters so the drive will auto-spin-up when a * disk is inserted. */ static void set_drive_params(int want_doublespeed) { unsigned char res_reg[12]; unsigned int res_size; unsigned char params[3]; params[0] = SONY_SD_AUTO_SPIN_DOWN_TIME; params[1] = 0x00; /* Never spin down the drive. */ do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, params, 2, res_reg, &res_size); if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { printk(KERN_NOTICE PFX "Unable to set spin-down time: 0x%2.2x\n", res_reg[1]); } params[0] = SONY_SD_MECH_CONTROL; params[1] = SONY_AUTO_SPIN_UP_BIT; /* Set auto spin up */ if (is_auto_eject) params[1] |= SONY_AUTO_EJECT_BIT; if (is_double_speed && want_doublespeed) { params[1] |= SONY_DOUBLE_SPEED_BIT; /* Set the drive to double speed if possible */ } do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, params, 2, res_reg, &res_size); if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { printk(KERN_NOTICE PFX "Unable to set mechanical " "parameters: 0x%2.2x\n", res_reg[1]); } } /* * Uniform cdrom interface function * select reading speed for data access */ static int scd_select_speed(struct cdrom_device_info *cdi, int speed) { if (speed == 0) sony_speed = 1; else sony_speed = speed - 1; if (down_interruptible(&sony_sem)) return -ERESTARTSYS; set_drive_params(sony_speed); up(&sony_sem); return 0; } /* * Uniform cdrom interface function * lock or unlock eject button */ static int scd_lock_door(struct cdrom_device_info *cdi, int lock) { if (lock == 0) { is_auto_eject = 1; } else { is_auto_eject = 0; } if (down_interruptible(&sony_sem)) return -ERESTARTSYS; set_drive_params(sony_speed); up(&sony_sem); return 0; } /* * This code will reset the drive and attempt to restore sane parameters. */ static void restart_on_error(void) { unsigned char res_reg[12]; unsigned int res_size; unsigned long retry_count; printk(KERN_NOTICE PFX "Resetting drive on error\n"); reset_drive(); retry_count = jiffies + SONY_RESET_TIMEOUT; while (time_before(jiffies, retry_count) && (!is_attention())) { sony_sleep(); } set_drive_params(sony_speed); do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size); if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { printk(KERN_NOTICE PFX "Unable to spin up drive: 0x%2.2x\n", res_reg[1]); } msleep(2000); sony_get_toc(); } /* * This routine writes data to the parameter register. Since this should * happen fairly fast, it is polled with no OS waits between. */ static int write_params(unsigned char *params, int num_params) { unsigned int retry_count; retry_count = SONY_READY_RETRIES; while ((retry_count > 0) && (!is_param_write_rdy())) { retry_count--; } if (!is_param_write_rdy()) { return -EIO; } while (num_params > 0) { write_param(*params); params++; num_params--; } return 0; } /* * The following reads data from the command result register. It is a * fairly complex routine, all status info flows back through this * interface. The algorithm is stolen directly from the flowcharts in * the drive manual. */ static void get_result(unsigned char *result_buffer, unsigned int *result_size) { unsigned char a, b; int i; unsigned long retry_count; while (handle_sony_cd_attention()); /* Wait for the result data to be ready */ retry_count = jiffies + SONY_JIFFIES_TIMEOUT; while (time_before(jiffies, retry_count) && (is_busy() || (!(is_result_ready())))) { sony_sleep(); while (handle_sony_cd_attention()); } if (is_busy() || (!(is_result_ready()))) { pr_debug(PFX "timeout out %d\n", __LINE__); result_buffer[0] = 0x20; result_buffer[1] = SONY_TIMEOUT_OP_ERR; *result_size = 2; return; } /* * Get the first two bytes. This determines what else needs * to be done. */ clear_result_ready(); a = read_result_register(); *result_buffer = a; result_buffer++; /* Check for block error status result. */ if ((a & 0xf0) == 0x50) { *result_size = 1; return; } b = read_result_register(); *result_buffer = b; result_buffer++; *result_size = 2; /* * 0x20 means an error occurred. Byte 2 will have the error code. * Otherwise, the command succeeded, byte 2 will have the count of * how many more status bytes are coming. * * The result register can be read 10 bytes at a time, a wait for * result ready to be asserted must be done between every 10 bytes. */ if ((a & 0xf0) != 0x20) { if (b > 8) { for (i = 0; i < 8; i++) { *result_buffer = read_result_register(); result_buffer++; (*result_size)++; } b = b - 8; while (b > 10) { retry_count = SONY_READY_RETRIES; while ((retry_count > 0) && (!is_result_ready())) { retry_count--; } if (!is_result_ready()) { pr_debug(PFX "timeout out %d\n", __LINE__); result_buffer[0] = 0x20; result_buffer[1] = SONY_TIMEOUT_OP_ERR; *result_size = 2; return; } clear_result_ready(); for (i = 0; i < 10; i++) { *result_buffer = read_result_register(); result_buffer++; (*result_size)++; } b = b - 10; } if (b > 0) { retry_count = SONY_READY_RETRIES; while ((retry_count > 0) && (!is_result_ready())) { retry_count--; } if (!is_result_ready()) { pr_debug(PFX "timeout out %d\n", __LINE__); result_buffer[0] = 0x20; result_buffer[1] = SONY_TIMEOUT_OP_ERR; *result_size = 2; return; } } } while (b > 0) { *result_buffer = read_result_register(); result_buffer++; (*result_size)++; b--; } } } /* * Do a command that does not involve data transfer. This routine must * be re-entrant from the same task to support being called from the * data operation code when an error occurs. */ static void do_sony_cd_cmd(unsigned char cmd, unsigned char *params, unsigned int num_params, unsigned char *result_buffer, unsigned int *result_size) { unsigned long retry_count; int num_retries = 0; retry_cd_operation: while (handle_sony_cd_attention()); retry_count = jiffies + SONY_JIFFIES_TIMEOUT; while (time_before(jiffies, retry_count) && (is_busy())) { sony_sleep(); while (handle_sony_cd_attention()); } if (is_busy()) { pr_debug(PFX "timeout out %d\n", __LINE__); result_buffer[0] = 0x20; result_buffer[1] = SONY_TIMEOUT_OP_ERR; *result_size = 2; } else { clear_result_ready(); clear_param_reg(); write_params(params, num_params); write_cmd(cmd); get_result(result_buffer, result_size); } if (((result_buffer[0] & 0xf0) == 0x20) && (num_retries < MAX_CDU31A_RETRIES)) { num_retries++; msleep(100); goto retry_cd_operation; } } /* * Handle an attention from the drive. This will return 1 if it found one * or 0 if not (if one is found, the caller might want to call again). * * This routine counts the number of consecutive times it is called * (since this is always called from a while loop until it returns * a 0), and returns a 0 if it happens too many times. This will help * prevent a lockup. */ static int handle_sony_cd_attention(void) { unsigned char atten_code; static int num_consecutive_attentions = 0; volatile int val; #if 0 pr_debug(PFX "Entering %s\n", __FUNCTION__); #endif if (is_attention()) { if (num_consecutive_attentions > CDU31A_MAX_CONSECUTIVE_ATTENTIONS) { printk(KERN_NOTICE PFX "Too many consecutive " "attentions: %d\n", num_consecutive_attentions); num_consecutive_attentions = 0; pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); return 0; } clear_attention(); atten_code = read_result_register(); switch (atten_code) { /* Someone changed the CD. Mark it as changed */ case SONY_MECH_LOADED_ATTN: disk_changed = 1; sony_toc_read = 0; sony_audio_status = CDROM_AUDIO_NO_STATUS; sony_blocks_left = 0; break; case SONY_SPIN_DOWN_COMPLETE_ATTN: /* Mark the disk as spun down. */ sony_spun_up = 0; break; case SONY_AUDIO_PLAY_DONE_ATTN: sony_audio_status = CDROM_AUDIO_COMPLETED; read_subcode(); break; case SONY_EJECT_PUSHED_ATTN: if (is_auto_eject) { sony_audio_status = CDROM_AUDIO_INVALID; } break; case SONY_LEAD_IN_ERR_ATTN: case SONY_LEAD_OUT_ERR_ATTN: case SONY_DATA_TRACK_ERR_ATTN: case SONY_AUDIO_PLAYBACK_ERR_ATTN: sony_audio_status = CDROM_AUDIO_ERROR; break; } num_consecutive_attentions++; pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); return 1; } else if (abort_read_started) { while (is_result_reg_not_empty()) { val = read_result_register(); } clear_data_ready(); clear_result_ready(); /* Clear out the data */ while (is_data_requested()) { val = read_data_register(); } abort_read_started = 0; pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); return 1; } num_consecutive_attentions = 0; #if 0 pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); #endif return 0; } /* Convert from an integer 0-99 to BCD */ static inline unsigned int int_to_bcd(unsigned int val) { int retval; retval = (val / 10) << 4; retval = retval | val % 10; return retval; } /* Convert from BCD to an integer from 0-99 */ static unsigned int bcd_to_int(unsigned int bcd) { return (((bcd >> 4) & 0x0f) * 10) + (bcd & 0x0f); } /* * Convert a logical sector value (like the OS would want to use for * a block device) to an MSF format. */ static void log_to_msf(unsigned int log, unsigned char *msf) { log = log + LOG_START_OFFSET; msf[0] = int_to_bcd(log / 4500); log = log % 4500; msf[1] = int_to_bcd(log / 75); msf[2] = int_to_bcd(log % 75); } /* * Convert an MSF format to a logical sector. */ static unsigned int msf_to_log(unsigned char *msf) { unsigned int log; log = msf[2]; log += msf[1] * 75; log += msf[0] * 4500; log = log - LOG_START_OFFSET; return log; } /* * Take in integer size value and put it into a buffer like * the drive would want to see a number-of-sector value. */ static void size_to_buf(unsigned int size, unsigned char *buf) { buf[0] = size / 65536; size = size % 65536; buf[1] = size / 256; buf[2] = size % 256; } /* Starts a read operation. Returns 0 on success and 1 on failure. The read operation used here allows multiple sequential sectors to be read and status returned for each sector. The driver will read the output one at a time as the requests come and abort the operation if the requested sector is not the next one from the drive. */ static int start_request(unsigned int sector, unsigned int nsect) { unsigned char params[6]; unsigned long retry_count; pr_debug(PFX "Entering %s\n", __FUNCTION__); log_to_msf(sector, params); size_to_buf(nsect, &params[3]); /* * Clear any outstanding attentions and wait for the drive to * complete any pending operations. */ while (handle_sony_cd_attention()); retry_count = jiffies + SONY_JIFFIES_TIMEOUT; while (time_before(jiffies, retry_count) && (is_busy())) { sony_sleep(); while (handle_sony_cd_attention()); } if (is_busy()) { printk(KERN_NOTICE PFX "Timeout while waiting " "to issue command\n"); pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); return 1; } else { /* Issue the command */ clear_result_ready(); clear_param_reg(); write_params(params, 6); write_cmd(SONY_READ_BLKERR_STAT_CMD); sony_blocks_left = nsect * 4; sony_next_block = sector * 4; pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); return 0; } pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); } /* Abort a pending read operation. Clear all the drive status variables. */ static void abort_read(void) { unsigned char result_reg[2]; int result_size; volatile int val; do_sony_cd_cmd(SONY_ABORT_CMD, NULL, 0, result_reg, &result_size); if ((result_reg[0] & 0xf0) == 0x20) { printk(KERN_ERR PFX "Aborting read, %s error\n", translate_error(result_reg[1])); } while (is_result_reg_not_empty()) { val = read_result_register(); } clear_data_ready(); clear_result_ready(); /* Clear out the data */ while (is_data_requested()) { val = read_data_register(); } sony_blocks_left = 0; } /* Called when the timer times out. This will abort the pending read operation. */ static void handle_abort_timeout(unsigned long data) { pr_debug(PFX "Entering %s\n", __FUNCTION__); /* If it is in use, ignore it. */ if (down_trylock(&sony_sem) == 0) { /* We can't use abort_read(), because it will sleep or schedule in the timer interrupt. Just start the operation, finish it on the next access to the drive. */ clear_result_ready(); clear_param_reg(); write_cmd(SONY_ABORT_CMD); sony_blocks_left = 0; abort_read_started = 1; up(&sony_sem); } pr_debug(PFX "Leaving %s\n", __FUNCTION__); } /* Actually get one sector of data from the drive. */ static void input_data_sector(char *buffer) { pr_debug(PFX "Entering %s\n", __FUNCTION__); /* If an XA disk on a CDU31A, skip the first 12 bytes of data from the disk. The real data is after that. We can use audio_buffer. */ if (sony_xa_mode) insb(sony_cd_read_reg, audio_buffer, CD_XA_HEAD); clear_data_ready(); insb(sony_cd_read_reg, buffer, 2048); /* If an XA disk, we have to clear out the rest of the unused error correction data. We can use audio_buffer for that. */ if (sony_xa_mode) insb(sony_cd_read_reg, audio_buffer, CD_XA_TAIL); pr_debug(PFX "Leaving %s\n", __FUNCTION__); } /* read data from the drive. Note the nsect must be <= 4. */ static void read_data_block(char *buffer, unsigned int block, unsigned int nblocks, unsigned char res_reg[], int *res_size) { unsigned long retry_count; pr_debug(PFX "Entering %s\n", __FUNCTION__); res_reg[0] = 0; res_reg[1] = 0; *res_size = 0; /* Wait for the drive to tell us we have something */ retry_count = jiffies + SONY_JIFFIES_TIMEOUT; while (time_before(jiffies, retry_count) && !(is_data_ready())) { while (handle_sony_cd_attention()); sony_sleep(); } if (!(is_data_ready())) { if (is_result_ready()) { get_result(res_reg, res_size); if ((res_reg[0] & 0xf0) != 0x20) { printk(KERN_NOTICE PFX "Got result that should" " have been error: %d\n", res_reg[0]); res_reg[0] = 0x20; res_reg[1] = SONY_BAD_DATA_ERR; *res_size = 2; } abort_read(); } else { pr_debug(PFX "timeout out %d\n", __LINE__); res_reg[0] = 0x20; res_reg[1] = SONY_TIMEOUT_OP_ERR; *res_size = 2; abort_read(); } } else { input_data_sector(buffer); sony_blocks_left -= nblocks; sony_next_block += nblocks; /* Wait for the status from the drive. */ retry_count = jiffies + SONY_JIFFIES_TIMEOUT; while (time_before(jiffies, retry_count) && !(is_result_ready())) { while (handle_sony_cd_attention()); sony_sleep(); } if (!is_result_ready()) { pr_debug(PFX "timeout out %d\n", __LINE__); res_reg[0] = 0x20; res_reg[1] = SONY_TIMEOUT_OP_ERR; *res_size = 2; abort_read(); } else { get_result(res_reg, res_size); /* If we got a buffer status, handle that. */ if ((res_reg[0] & 0xf0) == 0x50) { if ((res_reg[0] == SONY_NO_CIRC_ERR_BLK_STAT) || (res_reg[0] == SONY_NO_LECC_ERR_BLK_STAT) || (res_reg[0] == SONY_RECOV_LECC_ERR_BLK_STAT)) { /* nothing here */ } else { printk(KERN_ERR PFX "Data block " "error: 0x%x\n", res_reg[0]); res_reg[0] = 0x20; res_reg[1] = SONY_BAD_DATA_ERR; *res_size = 2; } /* Final transfer is done for read command, get final result. */ if (sony_blocks_left == 0) { get_result(res_reg, res_size); } } else if ((res_reg[0] & 0xf0) != 0x20) { /* The drive gave me bad status, I don't know what to do. Reset the driver and return an error. */ printk(KERN_ERR PFX "Invalid block " "status: 0x%x\n", res_reg[0]); restart_on_error(); res_reg[0] = 0x20; res_reg[1] = SONY_BAD_DATA_ERR; *res_size = 2; } } } pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); } /* * The OS calls this to perform a read or write operation to the drive. * Write obviously fail. Reads to a read ahead of sony_buffer_size * bytes to help speed operations. This especially helps since the OS * uses 1024 byte blocks and the drive uses 2048 byte blocks. Since most * data access on a CD is done sequentially, this saves a lot of operations. */ static void do_cdu31a_request(request_queue_t * q) { struct request *req; int block, nblock, num_retries; unsigned char res_reg[12]; unsigned int res_size; pr_debug(PFX "Entering %s\n", __FUNCTION__); spin_unlock_irq(q->queue_lock); if (down_interruptible(&sony_sem)) { spin_lock_irq(q->queue_lock); return; } /* Get drive status before doing anything. */ while (handle_sony_cd_attention()); /* Make sure we have a valid TOC. */ sony_get_toc(); /* Make sure the timer is cancelled. */ del_timer(&cdu31a_abort_timer); while (1) { /* * The beginning here is stolen from the hard disk driver. I hope * it's right. */ req = elv_next_request(q); if (!req) goto end_do_cdu31a_request; if (!sony_spun_up) scd_spinup(); block = req->sector; nblock = req->nr_sectors; pr_debug(PFX "request at block %d, length %d blocks\n", block, nblock); if (!sony_toc_read) { printk(KERN_NOTICE PFX "TOC not read\n"); end_request(req, 0); continue; } /* WTF??? */ if (!blk_fs_request(req)) { end_request(req, 0); continue; } if (rq_data_dir(req) == WRITE) { end_request(req, 0); continue; } /* * If the block address is invalid or the request goes beyond the end of * the media, return an error. */ if (((block + nblock) / 4) >= sony_toc.lead_out_start_lba) { printk(KERN_NOTICE PFX "Request past end of media\n"); end_request(req, 0); continue; } if (nblock > 4) nblock = 4; num_retries = 0; try_read_again: while (handle_sony_cd_attention()); if (!sony_toc_read) { printk(KERN_NOTICE PFX "TOC not read\n"); end_request(req, 0); continue; } /* If no data is left to be read from the drive, start the next request. */ if (sony_blocks_left == 0) { if (start_request(block / 4, nblock / 4)) { end_request(req, 0); continue; } } /* If the requested block is not the next one waiting in the driver, abort the current operation and start a new one. */ else if (block != sony_next_block) { pr_debug(PFX "Read for block %d, expected %d\n", block, sony_next_block); abort_read(); if (!sony_toc_read) { printk(KERN_NOTICE PFX "TOC not read\n"); end_request(req, 0); continue; } if (start_request(block / 4, nblock / 4)) { printk(KERN_NOTICE PFX "start request failed\n"); end_request(req, 0); continue; } } read_data_block(req->buffer, block, nblock, res_reg, &res_size); if (res_reg[0] != 0x20) { if (!end_that_request_first(req, 1, nblock)) { spin_lock_irq(q->queue_lock); blkdev_dequeue_request(req); end_that_request_last(req, 1); spin_unlock_irq(q->queue_lock); } continue; } if (num_retries > MAX_CDU31A_RETRIES) { end_request(req, 0); continue; } num_retries++; if (res_reg[1] == SONY_NOT_SPIN_ERR) { do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size); } else { printk(KERN_NOTICE PFX "%s error for block %d, nblock %d\n", translate_error(res_reg[1]), block, nblock); } goto try_read_again; } end_do_cdu31a_request: #if 0 /* After finished, cancel any pending operations. */ abort_read(); #else /* Start a timer to time out after a while to disable the read. */ cdu31a_abort_timer.expires = jiffies + 2 * HZ; /* Wait 2 seconds */ add_timer(&cdu31a_abort_timer); #endif up(&sony_sem); spin_lock_irq(q->queue_lock); pr_debug(PFX "Leaving %s at %d\n", __FUNCTION__, __LINE__); } /* * Read the table of contents from the drive and set up TOC if * successful. */ static void sony_get_toc(void) { unsigned char res_reg[2]; unsigned int res_size; unsigned char parms[1]; int session; int num_spin_ups; int totaltracks = 0; int mint = 99; int maxt = 0; pr_debug(PFX "Entering %s\n", __FUNCTION__); num_spin_ups = 0; if (!sony_toc_read) { respinup_on_gettoc: /* Ignore the result, since it might error if spinning already. */ do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size); do_sony_cd_cmd(SONY_READ_TOC_CMD, NULL, 0, res_reg, &res_size); /* The drive sometimes returns error 0. I don't know why, but ignore it. It seems to mean the drive has already done the operation. */ if ((res_size < 2) || ((res_reg[0] != 0) && (res_reg[1] != 0))) { /* If the drive is already playing, it's ok. */ if ((res_reg[1] == SONY_AUDIO_PLAYING_ERR) || (res_reg[1] == 0)) { goto gettoc_drive_spinning; } /* If the drive says it is not spun up (even though we just did it!) then retry the operation at least a few times. */ if ((res_reg[1] == SONY_NOT_SPIN_ERR) && (num_spin_ups < MAX_CDU31A_RETRIES)) { num_spin_ups++; goto respinup_on_gettoc; } printk("cdu31a: Error reading TOC: %x %s\n", res_reg[0], translate_error(res_reg[1])); return; } gettoc_drive_spinning: /* The idea here is we keep asking for sessions until the command fails. Then we know what the last valid session on the disk is. No need to check session 0, since session 0 is the same as session 1; the command returns different information if you give it 0. */ #if DEBUG memset(&sony_toc, 0x0e, sizeof(sony_toc)); memset(&single_toc, 0x0f, sizeof(single_toc)); #endif session = 1; while (1) { /* This seems to slow things down enough to make it work. This * appears to be a problem in do_sony_cd_cmd. This printk seems * to address the symptoms... -Erik */ pr_debug(PFX "Trying session %d\n", session); parms[0] = session; do_sony_cd_cmd(SONY_READ_TOC_SPEC_CMD, parms, 1, res_reg, &res_size); pr_debug(PFX "%2.2x %2.2x\n", res_reg[0], res_reg[1]); if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { /* An error reading the TOC, this must be past the last session. */ if (session == 1) printk ("Yikes! Couldn't read any sessions!"); break; } pr_debug(PFX "Reading session %d\n", session); parms[0] = session; do_sony_cd_cmd(SONY_REQ_TOC_DATA_SPEC_CMD, parms, 1, (unsigned char *) &single_toc, &res_size); if ((res_size < 2) || ((single_toc.exec_status[0] & 0xf0) == 0x20)) { printk(KERN_ERR PFX "Error reading " "session %d: %x %s\n", session, single_toc.exec_status[0], translate_error(single_toc. exec_status[1])); /* An error reading the TOC. Return without sony_toc_read set. */ return; } pr_debug(PFX "add0 %01x, con0 %01x, poi0 %02x, " "1st trk %d, dsktyp %x, dum0 %x\n", single_toc.address0, single_toc.control0, single_toc.point0, bcd_to_int(single_toc.first_track_num), single_toc.disk_type, single_toc.dummy0); pr_debug(PFX "add1 %01x, con1 %01x, poi1 %02x, " "lst trk %d, dummy1 %x, dum2 %x\n", single_toc.address1, single_toc.control1, single_toc.point1, bcd_to_int(single_toc.last_track_num), single_toc.dummy1, single_toc.dummy2); pr_debug(PFX "add2 %01x, con2 %01x, poi2 %02x " "leadout start min %d, sec %d, frame %d\n", single_toc.address2, single_toc.control2, single_toc.point2, bcd_to_int(single_toc.lead_out_start_msf[0]), bcd_to_int(single_toc.lead_out_start_msf[1]), bcd_to_int(single_toc.lead_out_start_msf[2])); if (res_size > 18 && single_toc.pointb0 > 0xaf) pr_debug(PFX "addb0 %01x, conb0 %01x, poib0 %02x, nextsession min %d, sec %d, frame %d\n" "#mode5_ptrs %02d, max_start_outer_leadout_msf min %d, sec %d, frame %d\n", single_toc.addressb0, single_toc.controlb0, single_toc.pointb0, bcd_to_int(single_toc. next_poss_prog_area_msf [0]), bcd_to_int(single_toc. next_poss_prog_area_msf [1]), bcd_to_int(single_toc. next_poss_prog_area_msf [2]), single_toc.num_mode_5_pointers, bcd_to_int(single_toc. max_start_outer_leadout_msf [0]), bcd_to_int(single_toc. max_start_outer_leadout_msf [1]), bcd_to_int(single_toc. max_start_outer_leadout_msf [2])); if (res_size > 27 && single_toc.pointb1 > 0xaf) pr_debug(PFX "addb1 %01x, conb1 %01x, poib1 %02x, %x %x %x %x #skipint_ptrs %d, #skiptrkassign %d %x\n", single_toc.addressb1, single_toc.controlb1, single_toc.pointb1, single_toc.dummyb0_1[0], single_toc.dummyb0_1[1], single_toc.dummyb0_1[2], single_toc.dummyb0_1[3], single_toc.num_skip_interval_pointers, single_toc.num_skip_track_assignments, single_toc.dummyb0_2); if (res_size > 36 && single_toc.pointb2 > 0xaf) pr_debug(PFX "addb2 %01x, conb2 %01x, poib2 %02x, %02x %02x %02x %02x %02x %02x %02x\n", single_toc.addressb2, single_toc.controlb2, single_toc.pointb2, single_toc.tracksb2[0], single_toc.tracksb2[1], single_toc.tracksb2[2], single_toc.tracksb2[3], single_toc.tracksb2[4], single_toc.tracksb2[5], single_toc.tracksb2[6]); if (res_size > 45 && single_toc.pointb3 > 0xaf) pr_debug(PFX "addb3 %01x, conb3 %01x, poib3 %02x, %02x %02x %02x %02x %02x %02x %02x\n", single_toc.addressb3, single_toc.controlb3, single_toc.pointb3, single_toc.tracksb3[0], single_toc.tracksb3[1], single_toc.tracksb3[2], single_toc.tracksb3[3], single_toc.tracksb3[4], single_toc.tracksb3[5], single_toc.tracksb3[6]); if (res_size > 54 && single_toc.pointb4 > 0xaf) pr_debug(PFX "addb4 %01x, conb4 %01x, poib4 %02x, %02x %02x %02x %02x %02x %02x %02x\n", single_toc.addressb4, single_toc.controlb4, single_toc.pointb4, single_toc.tracksb4[0], single_toc.tracksb4[1], single_toc.tracksb4[2], single_toc.tracksb4[3], single_toc.tracksb4[4], single_toc.tracksb4[5], single_toc.tracksb4[6]); if (res_size > 63 && single_toc.pointc0 > 0xaf) pr_debug(PFX "addc0 %01x, conc0 %01x, poic0 %02x, %02x %02x %02x %02x %02x %02x %02x\n", single_toc.addressc0, single_toc.controlc0, single_toc.pointc0, single_toc.dummyc0[0], single_toc.dummyc0[1], single_toc.dummyc0[2], single_toc.dummyc0[3], single_toc.dummyc0[4], single_toc.dummyc0[5], single_toc.dummyc0[6]); #undef DEBUG #define DEBUG 0 sony_toc.lead_out_start_msf[0] = bcd_to_int(single_toc.lead_out_start_msf[0]); sony_toc.lead_out_start_msf[1] = bcd_to_int(single_toc.lead_out_start_msf[1]); sony_toc.lead_out_start_msf[2] = bcd_to_int(single_toc.lead_out_start_msf[2]); sony_toc.lead_out_start_lba = single_toc.lead_out_start_lba = msf_to_log(sony_toc.lead_out_start_msf); /* For points that do not exist, move the data over them to the right location. */ if (single_toc.pointb0 != 0xb0) { memmove(((char *) &single_toc) + 27, ((char *) &single_toc) + 18, res_size - 18); res_size += 9; } else if (res_size > 18) { sony_toc.lead_out_start_msf[0] = bcd_to_int(single_toc. max_start_outer_leadout_msf [0]); sony_toc.lead_out_start_msf[1] = bcd_to_int(single_toc. max_start_outer_leadout_msf [1]); sony_toc.lead_out_start_msf[2] = bcd_to_int(single_toc. max_start_outer_leadout_msf [2]); sony_toc.lead_out_start_lba = msf_to_log(sony_toc. lead_out_start_msf); } if (single_toc.pointb1 != 0xb1) { memmove(((char *) &single_toc) + 36, ((char *) &single_toc) + 27, res_size - 27); res_size += 9; } if (single_toc.pointb2 != 0xb2) { memmove(((char *) &single_toc) + 45, ((char *) &single_toc) + 36, res_size - 36); res_size += 9; } if (single_toc.pointb3 != 0xb3) { memmove(((char *) &single_toc) + 54, ((char *) &single_toc) + 45, res_size - 45); res_size += 9; } if (single_toc.pointb4 != 0xb4) { memmove(((char *) &single_toc) + 63, ((char *) &single_toc) + 54, res_size - 54); res_size += 9; } if (single_toc.pointc0 != 0xc0) { memmove(((char *) &single_toc) + 72, ((char *) &single_toc) + 63, res_size - 63); res_size += 9; } #if DEBUG printk(PRINT_INFO PFX "start track lba %u, " "leadout start lba %u\n", single_toc.start_track_lba, single_toc.lead_out_start_lba); { int i; for (i = 0; i < 1 + bcd_to_int(single_toc.last_track_num) - bcd_to_int(single_toc. first_track_num); i++) { printk(KERN_INFO PFX "trk %02d: add 0x%01x, con 0x%01x, track %02d, start min %02d, sec %02d, frame %02d\n", i, single_toc.tracks[i].address, single_toc.tracks[i].control, bcd_to_int(single_toc. tracks[i].track), bcd_to_int(single_toc. tracks[i]. track_start_msf [0]), bcd_to_int(single_toc. tracks[i]. track_start_msf [1]), bcd_to_int(single_toc. tracks[i]. track_start_msf [2])); if (mint > bcd_to_int(single_toc. tracks[i].track)) mint = bcd_to_int(single_toc. tracks[i]. track); if (maxt < bcd_to_int(single_toc. tracks[i].track)) maxt = bcd_to_int(single_toc. tracks[i]. track); } printk(KERN_INFO PFX "min track number %d, " "max track number %d\n", mint, maxt); } #endif /* prepare a special table of contents for a CD-I disc. They don't have one. */ if (single_toc.disk_type == 0x10 && single_toc.first_track_num == 2 && single_toc.last_track_num == 2 /* CD-I */ ) { sony_toc.tracks[totaltracks].address = 1; sony_toc.tracks[totaltracks].control = 4; /* force data tracks */ sony_toc.tracks[totaltracks].track = 1; sony_toc.tracks[totaltracks]. track_start_msf[0] = 0; sony_toc.tracks[totaltracks]. track_start_msf[1] = 2; sony_toc.tracks[totaltracks]. track_start_msf[2] = 0; mint = maxt = 1; totaltracks++; } else /* gather track entries from this session */ { int i; for (i = 0; i < 1 + bcd_to_int(single_toc.last_track_num) - bcd_to_int(single_toc. first_track_num); i++, totaltracks++) { sony_toc.tracks[totaltracks]. address = single_toc.tracks[i].address; sony_toc.tracks[totaltracks]. control = single_toc.tracks[i].control; sony_toc.tracks[totaltracks]. track = bcd_to_int(single_toc. tracks[i].track); sony_toc.tracks[totaltracks]. track_start_msf[0] = bcd_to_int(single_toc. tracks[i]. track_start_msf[0]); sony_toc.tracks[totaltracks]. track_start_msf[1] = bcd_to_int(single_toc. tracks[i]. track_start_msf[1]); sony_toc.tracks[totaltracks]. track_start_msf[2] = bcd_to_int(single_toc. tracks[i]. track_start_msf[2]); if (i == 0) single_toc. start_track_lba = msf_to_log(sony_toc. tracks [totaltracks]. track_start_msf); if (mint > sony_toc.tracks[totaltracks]. track) mint = sony_toc. tracks[totaltracks]. track; if (maxt < sony_toc.tracks[totaltracks]. track) maxt = sony_toc. tracks[totaltracks]. track; } } sony_toc.first_track_num = mint; sony_toc.last_track_num = maxt; /* Disk type of last session wins. For example: CD-Extra has disk type 0 for the first session, so a dumb HiFi CD player thinks it is a plain audio CD. We are interested in the disk type of the last session, which is 0x20 (XA) for CD-Extra, so we can access the data track ... */ sony_toc.disk_type = single_toc.disk_type; sony_toc.sessions = session; /* don't believe everything :-) */ if (session == 1) single_toc.start_track_lba = 0; sony_toc.start_track_lba = single_toc.start_track_lba; if (session > 1 && single_toc.pointb0 == 0xb0 && sony_toc.lead_out_start_lba == single_toc.lead_out_start_lba) { break; } /* Let's not get carried away... */ if (session > 40) { printk(KERN_NOTICE PFX "too many sessions: " "%d\n", session); break; } session++; } sony_toc.track_entries = totaltracks; /* add one entry for the LAST track with track number CDROM_LEADOUT */ sony_toc.tracks[totaltracks].address = single_toc.address2; sony_toc.tracks[totaltracks].control = single_toc.control2; sony_toc.tracks[totaltracks].track = CDROM_LEADOUT; sony_toc.tracks[totaltracks].track_start_msf[0] = sony_toc.lead_out_start_msf[0]; sony_toc.tracks[totaltracks].track_start_msf[1] = sony_toc.lead_out_start_msf[1]; sony_toc.tracks[totaltracks].track_start_msf[2] = sony_toc.lead_out_start_msf[2]; sony_toc_read = 1; pr_debug(PFX "Disk session %d, start track: %d, " "stop track: %d\n", session, single_toc.start_track_lba, single_toc.lead_out_start_lba); } pr_debug(PFX "Leaving %s\n", __FUNCTION__); } /* * Uniform cdrom interface function * return multisession offset and sector information */ static int scd_get_last_session(struct cdrom_device_info *cdi, struct cdrom_multisession *ms_info) { if (ms_info == NULL) return 1; if (!sony_toc_read) { if (down_interruptible(&sony_sem)) return -ERESTARTSYS; sony_get_toc(); up(&sony_sem); } ms_info->addr_format = CDROM_LBA; ms_info->addr.lba = sony_toc.start_track_lba; ms_info->xa_flag = sony_toc.disk_type == SONY_XA_DISK_TYPE || sony_toc.disk_type == 0x10 /* CDI */ ; return 0; } /* * Search for a specific track in the table of contents. */ static int find_track(int track) { int i; for (i = 0; i <= sony_toc.track_entries; i++) { if (sony_toc.tracks[i].track == track) { return i; } } return -1; } /* * Read the subcode and put it in last_sony_subcode for future use. */ static int read_subcode(void) { unsigned int res_size; do_sony_cd_cmd(SONY_REQ_SUBCODE_ADDRESS_CMD, NULL, 0, (unsigned char *) &last_sony_subcode, &res_size); if ((res_size < 2) || ((last_sony_subcode.exec_status[0] & 0xf0) == 0x20)) { printk(KERN_ERR PFX "Sony CDROM error %s (read_subcode)\n", translate_error(last_sony_subcode.exec_status[1])); return -EIO; } last_sony_subcode.track_num = bcd_to_int(last_sony_subcode.track_num); last_sony_subcode.index_num = bcd_to_int(last_sony_subcode.index_num); last_sony_subcode.abs_msf[0] = bcd_to_int(last_sony_subcode.abs_msf[0]); last_sony_subcode.abs_msf[1] = bcd_to_int(last_sony_subcode.abs_msf[1]); last_sony_subcode.abs_msf[2] = bcd_to_int(last_sony_subcode.abs_msf[2]); last_sony_subcode.rel_msf[0] = bcd_to_int(last_sony_subcode.rel_msf[0]); last_sony_subcode.rel_msf[1] = bcd_to_int(last_sony_subcode.rel_msf[1]); last_sony_subcode.rel_msf[2] = bcd_to_int(last_sony_subcode.rel_msf[2]); return 0; } /* * Uniform cdrom interface function * return the media catalog number found on some older audio cds */ static int scd_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) { unsigned char resbuffer[2 + 14]; unsigned char *mcnp = mcn->medium_catalog_number; unsigned char *resp = resbuffer + 3; unsigned int res_size; memset(mcn->medium_catalog_number, 0, 14); if (down_interruptible(&sony_sem)) return -ERESTARTSYS; do_sony_cd_cmd(SONY_REQ_UPC_EAN_CMD, NULL, 0, resbuffer, &res_size); up(&sony_sem); if ((res_size < 2) || ((resbuffer[0] & 0xf0) == 0x20)); else { /* packed bcd to single ASCII digits */ *mcnp++ = (*resp >> 4) + '0'; *mcnp++ = (*resp++ & 0x0f) + '0'; *mcnp++ = (*resp >> 4) + '0'; *mcnp++ = (*resp++ & 0x0f) + '0'; *mcnp++ = (*resp >> 4) + '0'; *mcnp++ = (*resp++ & 0x0f) + '0'; *mcnp++ = (*resp >> 4) + '0'; *mcnp++ = (*resp++ & 0x0f) + '0'; *mcnp++ = (*resp >> 4) + '0'; *mcnp++ = (*resp++ & 0x0f) + '0'; *mcnp++ = (*resp >> 4) + '0'; *mcnp++ = (*resp++ & 0x0f) + '0'; *mcnp++ = (*resp >> 4) + '0'; } *mcnp = '\0'; return 0; } /* * Get the subchannel info like the CDROMSUBCHNL command wants to see it. If * the drive is playing, the subchannel needs to be read (since it would be * changing). If the drive is paused or completed, the subcode information has * already been stored, just use that. The ioctl call wants things in decimal * (not BCD), so all the conversions are done. */ static int sony_get_subchnl_info(struct cdrom_subchnl *schi) { /* Get attention stuff */ while (handle_sony_cd_attention()); sony_get_toc(); if (!sony_toc_read) { return -EIO; } switch (sony_audio_status) { case CDROM_AUDIO_NO_STATUS: case CDROM_AUDIO_PLAY: if (read_subcode() < 0) { return -EIO; } break; case CDROM_AUDIO_PAUSED: case CDROM_AUDIO_COMPLETED: break; #if 0 case CDROM_AUDIO_NO_STATUS: schi->cdsc_audiostatus = sony_audio_status; return 0; break; #endif case CDROM_AUDIO_INVALID: case CDROM_AUDIO_ERROR: default: return -EIO; } schi->cdsc_audiostatus = sony_audio_status; schi->cdsc_adr = last_sony_subcode.address; schi->cdsc_ctrl = last_sony_subcode.control; schi->cdsc_trk = last_sony_subcode.track_num; schi->cdsc_ind = last_sony_subcode.index_num; if (schi->cdsc_format == CDROM_MSF) { schi->cdsc_absaddr.msf.minute = last_sony_subcode.abs_msf[0]; schi->cdsc_absaddr.msf.second = last_sony_subcode.abs_msf[1]; schi->cdsc_absaddr.msf.frame = last_sony_subcode.abs_msf[2]; schi->cdsc_reladdr.msf.minute = last_sony_subcode.rel_msf[0]; schi->cdsc_reladdr.msf.second = last_sony_subcode.rel_msf[1]; schi->cdsc_reladdr.msf.frame = last_sony_subcode.rel_msf[2]; } else if (schi->cdsc_format == CDROM_LBA) { schi->cdsc_absaddr.lba = msf_to_log(last_sony_subcode.abs_msf); schi->cdsc_reladdr.lba = msf_to_log(last_sony_subcode.rel_msf); } return 0; } /* Get audio data from the drive. This is fairly complex because I am looking for status and data at the same time, but if I get status then I just look for data. I need to get the status immediately so the switch from audio to data tracks will happen quickly. */ static void read_audio_data(char *buffer, unsigned char res_reg[], int *res_size) { unsigned long retry_count; int result_read; res_reg[0] = 0; res_reg[1] = 0; *res_size = 0; result_read = 0; /* Wait for the drive to tell us we have something */ retry_count = jiffies + SONY_JIFFIES_TIMEOUT; continue_read_audio_wait: while (time_before(jiffies, retry_count) && !(is_data_ready()) && !(is_result_ready() || result_read)) { while (handle_sony_cd_attention()); sony_sleep(); } if (!(is_data_ready())) { if (is_result_ready() && !result_read) { get_result(res_reg, res_size); /* Read block status and continue waiting for data. */ if ((res_reg[0] & 0xf0) == 0x50) { result_read = 1; goto continue_read_audio_wait; } /* Invalid data from the drive. Shut down the operation. */ else if ((res_reg[0] & 0xf0) != 0x20) { printk(KERN_WARNING PFX "Got result that " "should have been error: %d\n", res_reg[0]); res_reg[0] = 0x20; res_reg[1] = SONY_BAD_DATA_ERR; *res_size = 2; } abort_read(); } else { pr_debug(PFX "timeout out %d\n", __LINE__); res_reg[0] = 0x20; res_reg[1] = SONY_TIMEOUT_OP_ERR; *res_size = 2; abort_read(); } } else { clear_data_ready(); /* If data block, then get 2340 bytes offset by 12. */ if (sony_raw_data_mode) { insb(sony_cd_read_reg, buffer + CD_XA_HEAD, CD_FRAMESIZE_RAW1); } else { /* Audio gets the whole 2352 bytes. */ insb(sony_cd_read_reg, buffer, CD_FRAMESIZE_RAW); } /* If I haven't already gotten the result, get it now. */ if (!result_read) { /* Wait for the drive to tell us we have something */ retry_count = jiffies + SONY_JIFFIES_TIMEOUT; while (time_before(jiffies, retry_count) && !(is_result_ready())) { while (handle_sony_cd_attention()); sony_sleep(); } if (!is_result_ready()) { pr_debug(PFX "timeout out %d\n", __LINE__); res_reg[0] = 0x20; res_reg[1] = SONY_TIMEOUT_OP_ERR; *res_size = 2; abort_read(); return; } else { get_result(res_reg, res_size); } } if ((res_reg[0] & 0xf0) == 0x50) { if ((res_reg[0] == SONY_NO_CIRC_ERR_BLK_STAT) || (res_reg[0] == SONY_NO_LECC_ERR_BLK_STAT) || (res_reg[0] == SONY_RECOV_LECC_ERR_BLK_STAT) || (res_reg[0] == SONY_NO_ERR_DETECTION_STAT)) { /* Ok, nothing to do. */ } else { printk(KERN_ERR PFX "Data block error: 0x%x\n", res_reg[0]); res_reg[0] = 0x20; res_reg[1] = SONY_BAD_DATA_ERR; *res_size = 2; } } else if ((res_reg[0] & 0xf0) != 0x20) { /* The drive gave me bad status, I don't know what to do. Reset the driver and return an error. */ printk(KERN_NOTICE PFX "Invalid block status: 0x%x\n", res_reg[0]); restart_on_error(); res_reg[0] = 0x20; res_reg[1] = SONY_BAD_DATA_ERR; *res_size = 2; } } } /* Perform a raw data read. This will automatically detect the track type and read the proper data (audio or data). */ static int read_audio(struct cdrom_read_audio *ra) { int retval; unsigned char params[2]; unsigned char res_reg[12]; unsigned int res_size; unsigned int cframe; if (down_interruptible(&sony_sem)) return -ERESTARTSYS; if (!sony_spun_up) scd_spinup(); /* Set the drive to do raw operations. */ params[0] = SONY_SD_DECODE_PARAM; params[1] = 0x06 | sony_raw_data_mode; do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, params, 2, res_reg, &res_size); if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { printk(KERN_ERR PFX "Unable to set decode params: 0x%2.2x\n", res_reg[1]); retval = -EIO; goto out_up; } /* From here down, we have to goto exit_read_audio instead of returning because the drive parameters have to be set back to data before return. */ retval = 0; if (start_request(ra->addr.lba, ra->nframes)) { retval = -EIO; goto exit_read_audio; } /* For every requested frame. */ cframe = 0; while (cframe < ra->nframes) { read_audio_data(audio_buffer, res_reg, &res_size); if ((res_reg[0] & 0xf0) == 0x20) { if (res_reg[1] == SONY_BAD_DATA_ERR) { printk(KERN_ERR PFX "Data error on audio " "sector %d\n", ra->addr.lba + cframe); } else if (res_reg[1] == SONY_ILL_TRACK_R_ERR) { /* Illegal track type, change track types and start over. */ sony_raw_data_mode = (sony_raw_data_mode) ? 0 : 1; /* Set the drive mode. */ params[0] = SONY_SD_DECODE_PARAM; params[1] = 0x06 | sony_raw_data_mode; do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, params, 2, res_reg, &res_size); if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { printk(KERN_ERR PFX "Unable to set " "decode params: 0x%2.2x\n", res_reg[1]); retval = -EIO; goto exit_read_audio; } /* Restart the request on the current frame. */ if (start_request (ra->addr.lba + cframe, ra->nframes - cframe)) { retval = -EIO; goto exit_read_audio; } /* Don't go back to the top because don't want to get into and infinite loop. A lot of code gets duplicated, but that's no big deal, I don't guess. */ read_audio_data(audio_buffer, res_reg, &res_size); if ((res_reg[0] & 0xf0) == 0x20) { if (res_reg[1] == SONY_BAD_DATA_ERR) { printk(KERN_ERR PFX "Data error" " on audio sector %d\n", ra->addr.lba + cframe); } else { printk(KERN_ERR PFX "Error reading audio data on sector %d: %s\n", ra->addr.lba + cframe, translate_error (res_reg[1])); retval = -EIO; goto exit_read_audio; } } else if (copy_to_user(ra->buf + (CD_FRAMESIZE_RAW * cframe), audio_buffer, CD_FRAMESIZE_RAW)) { retval = -EFAULT; goto exit_read_audio; } } else { printk(KERN_ERR PFX "Error reading audio " "data on sector %d: %s\n", ra->addr.lba + cframe, translate_error(res_reg[1])); retval = -EIO; goto exit_read_audio; } } else if (copy_to_user(ra->buf + (CD_FRAMESIZE_RAW * cframe), (char *)audio_buffer, CD_FRAMESIZE_RAW)) { retval = -EFAULT; goto exit_read_audio; } cframe++; } get_result(res_reg, &res_size); if ((res_reg[0] & 0xf0) == 0x20) { printk(KERN_ERR PFX "Error return from audio read: %s\n", translate_error(res_reg[1])); retval = -EIO; goto exit_read_audio; } exit_read_audio: /* Set the drive mode back to the proper one for the disk. */ params[0] = SONY_SD_DECODE_PARAM; if (!sony_xa_mode) { params[1] = 0x0f; } else { params[1] = 0x07; } do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD, params, 2, res_reg, &res_size); if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { printk(KERN_ERR PFX "Unable to reset decode params: 0x%2.2x\n", res_reg[1]); retval = -EIO; } out_up: up(&sony_sem); return retval; } static int do_sony_cd_cmd_chk(const char *name, unsigned char cmd, unsigned char *params, unsigned int num_params, unsigned char *result_buffer, unsigned int *result_size) { do_sony_cd_cmd(cmd, params, num_params, result_buffer, result_size); if ((*result_size < 2) || ((result_buffer[0] & 0xf0) == 0x20)) { printk(KERN_ERR PFX "Error %s (CDROM%s)\n", translate_error(result_buffer[1]), name); return -EIO; } return 0; } /* * Uniform cdrom interface function * open the tray */ static int scd_tray_move(struct cdrom_device_info *cdi, int position) { int retval; if (down_interruptible(&sony_sem)) return -ERESTARTSYS; if (position == 1 /* open tray */ ) { unsigned char res_reg[12]; unsigned int res_size; do_sony_cd_cmd(SONY_AUDIO_STOP_CMD, NULL, 0, res_reg, &res_size); do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, &res_size); sony_audio_status = CDROM_AUDIO_INVALID; retval = do_sony_cd_cmd_chk("EJECT", SONY_EJECT_CMD, NULL, 0, res_reg, &res_size); } else { if (0 == scd_spinup()) sony_spun_up = 1; retval = 0; } up(&sony_sem); return retval; } /* * The big ugly ioctl handler. */ static int scd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) { unsigned char res_reg[12]; unsigned int res_size; unsigned char params[7]; int i, retval; if (down_interruptible(&sony_sem)) return -ERESTARTSYS; switch (cmd) { case CDROMSTART: /* Spin up the drive */ retval = do_sony_cd_cmd_chk("START", SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size); break; case CDROMSTOP: /* Spin down the drive */ do_sony_cd_cmd(SONY_AUDIO_STOP_CMD, NULL, 0, res_reg, &res_size); /* * Spin the drive down, ignoring the error if the disk was * already not spinning. */ sony_audio_status = CDROM_AUDIO_NO_STATUS; retval = do_sony_cd_cmd_chk("STOP", SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, &res_size); break; case CDROMPAUSE: /* Pause the drive */ if (do_sony_cd_cmd_chk ("PAUSE", SONY_AUDIO_STOP_CMD, NULL, 0, res_reg, &res_size)) { retval = -EIO; break; } /* Get the current position and save it for resuming */ if (read_subcode() < 0) { retval = -EIO; break; } cur_pos_msf[0] = last_sony_subcode.abs_msf[0]; cur_pos_msf[1] = last_sony_subcode.abs_msf[1]; cur_pos_msf[2] = last_sony_subcode.abs_msf[2]; sony_audio_status = CDROM_AUDIO_PAUSED; retval = 0; break; case CDROMRESUME: /* Start the drive after being paused */ if (sony_audio_status != CDROM_AUDIO_PAUSED) { retval = -EINVAL; break; } do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size); /* Start the drive at the saved position. */ params[1] = int_to_bcd(cur_pos_msf[0]); params[2] = int_to_bcd(cur_pos_msf[1]); params[3] = int_to_bcd(cur_pos_msf[2]); params[4] = int_to_bcd(final_pos_msf[0]); params[5] = int_to_bcd(final_pos_msf[1]); params[6] = int_to_bcd(final_pos_msf[2]); params[0] = 0x03; if (do_sony_cd_cmd_chk ("RESUME", SONY_AUDIO_PLAYBACK_CMD, params, 7, res_reg, &res_size) < 0) { retval = -EIO; break; } sony_audio_status = CDROM_AUDIO_PLAY; retval = 0; break; case CDROMPLAYMSF: /* Play starting at the given MSF address. */ do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size); /* The parameters are given in int, must be converted */ for (i = 1; i < 7; i++) { params[i] = int_to_bcd(((unsigned char *) arg)[i - 1]); } params[0] = 0x03; if (do_sony_cd_cmd_chk ("PLAYMSF", SONY_AUDIO_PLAYBACK_CMD, params, 7, res_reg, &res_size) < 0) { retval = -EIO; break; } /* Save the final position for pauses and resumes */ final_pos_msf[0] = bcd_to_int(params[4]); final_pos_msf[1] = bcd_to_int(params[5]); final_pos_msf[2] = bcd_to_int(params[6]); sony_audio_status = CDROM_AUDIO_PLAY; retval = 0; break; case CDROMREADTOCHDR: /* Read the table of contents header */ { struct cdrom_tochdr *hdr; sony_get_toc(); if (!sony_toc_read) { retval = -EIO; break; } hdr = (struct cdrom_tochdr *) arg; hdr->cdth_trk0 = sony_toc.first_track_num; hdr->cdth_trk1 = sony_toc.last_track_num; } retval = 0; break; case CDROMREADTOCENTRY: /* Read a given table of contents entry */ { struct cdrom_tocentry *entry; int track_idx; unsigned char *msf_val = NULL; sony_get_toc(); if (!sony_toc_read) { retval = -EIO; break; } entry = (struct cdrom_tocentry *) arg; track_idx = find_track(entry->cdte_track); if (track_idx < 0) { retval = -EINVAL; break; } entry->cdte_adr = sony_toc.tracks[track_idx].address; entry->cdte_ctrl = sony_toc.tracks[track_idx].control; msf_val = sony_toc.tracks[track_idx].track_start_msf; /* Logical buffer address or MSF format requested? */ if (entry->cdte_format == CDROM_LBA) { entry->cdte_addr.lba = msf_to_log(msf_val); } else if (entry->cdte_format == CDROM_MSF) { entry->cdte_addr.msf.minute = *msf_val; entry->cdte_addr.msf.second = *(msf_val + 1); entry->cdte_addr.msf.frame = *(msf_val + 2); } } retval = 0; break; case CDROMPLAYTRKIND: /* Play a track. This currently ignores index. */ { struct cdrom_ti *ti = (struct cdrom_ti *) arg; int track_idx; sony_get_toc(); if (!sony_toc_read) { retval = -EIO; break; } if ((ti->cdti_trk0 < sony_toc.first_track_num) || (ti->cdti_trk0 > sony_toc.last_track_num) || (ti->cdti_trk1 < ti->cdti_trk0)) { retval = -EINVAL; break; } track_idx = find_track(ti->cdti_trk0); if (track_idx < 0) { retval = -EINVAL; break; } params[1] = int_to_bcd(sony_toc.tracks[track_idx]. track_start_msf[0]); params[2] = int_to_bcd(sony_toc.tracks[track_idx]. track_start_msf[1]); params[3] = int_to_bcd(sony_toc.tracks[track_idx]. track_start_msf[2]); /* * If we want to stop after the last track, use the lead-out * MSF to do that. */ if (ti->cdti_trk1 >= sony_toc.last_track_num) { track_idx = find_track(CDROM_LEADOUT); } else { track_idx = find_track(ti->cdti_trk1 + 1); } if (track_idx < 0) { retval = -EINVAL; break; } params[4] = int_to_bcd(sony_toc.tracks[track_idx]. track_start_msf[0]); params[5] = int_to_bcd(sony_toc.tracks[track_idx]. track_start_msf[1]); params[6] = int_to_bcd(sony_toc.tracks[track_idx]. track_start_msf[2]); params[0] = 0x03; do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size); do_sony_cd_cmd(SONY_AUDIO_PLAYBACK_CMD, params, 7, res_reg, &res_size); if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { printk(KERN_ERR PFX "Params: %x %x %x %x %x %x %x\n", params[0], params[1], params[2], params[3], params[4], params[5], params[6]); printk(KERN_ERR PFX "Error %s (CDROMPLAYTRKIND)\n", translate_error(res_reg[1])); retval = -EIO; break; } /* Save the final position for pauses and resumes */ final_pos_msf[0] = bcd_to_int(params[4]); final_pos_msf[1] = bcd_to_int(params[5]); final_pos_msf[2] = bcd_to_int(params[6]); sony_audio_status = CDROM_AUDIO_PLAY; retval = 0; break; } case CDROMVOLCTRL: /* Volume control. What volume does this change, anyway? */ { struct cdrom_volctrl *volctrl = (struct cdrom_volctrl *) arg; params[0] = SONY_SD_AUDIO_VOLUME; params[1] = volctrl->channel0; params[2] = volctrl->channel1; retval = do_sony_cd_cmd_chk("VOLCTRL", SONY_SET_DRIVE_PARAM_CMD, params, 3, res_reg, &res_size); break; } case CDROMSUBCHNL: /* Get subchannel info */ retval = sony_get_subchnl_info((struct cdrom_subchnl *) arg); break; default: retval = -EINVAL; break; } up(&sony_sem); return retval; } static int scd_read_audio(struct cdrom_device_info *cdi, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; int retval; if (down_interruptible(&sony_sem)) return -ERESTARTSYS; switch (cmd) { case CDROMREADAUDIO: /* Read 2352 byte audio tracks and 2340 byte raw data tracks. */ { struct cdrom_read_audio ra; sony_get_toc(); if (!sony_toc_read) { retval = -EIO; break; } if (copy_from_user(&ra, argp, sizeof(ra))) {