IRC log of #maemo-devel for Wednesday, 2010-09-08

*** pH5 has quit IRC00:24
*** csaavedra has quit IRC00:41
*** nonick has quit IRC01:12
*** _0x47 has quit IRC02:16
MNZDocScrutinizer, I read the alsa api a bunch. Documentation is not all that great. I think the best way to expose the coefficients would be through a 'hardware dependent device'02:40
MNZbasically I implement a bunch of callbacks and register with the alsa system, and userspace can access it through libalsa abstraction02:41
MNZand it's not a mixer control, because it really shouldn't be02:41
DocScrutinizerlogically it should, but meh02:42
MNZno I mean if it's going to be coeffs, then it obviously shouldn't be mixer controls'02:43
MNZif it was going to be levels/gain, then yeah I guess02:43
DocScrutinizerthe raw coeffs obviously don't fit into alsa mixer02:44
MNZso final thoughts, should I go this way?02:44
DocScrutinizerdoesn't make sense to adjust coeff values via sliders :-P02:44
DocScrutinizersound good02:44
DocScrutinizerhonestly, as long as there's any reasonable way to shoot the raw coeff values to the chip, it's much better than now02:46
DocScrutinizereverything beyond probably has to be done in userspace anyway02:47
MNZAgreed02:47
DocScrutinizermaybe it's best to expose the coeff registers as /sys or /dev, and have a "plugin" for ALSA (analog to e.g. softvol, regarding sliders etc) which implements >>control.16 {comment.access 'read write'; comment.type ENUMERATED; comment.count 1; comment.item.0 'off'; comment.item.1 'lowpass filter'; comment.item.2 'bandpass'; <etc>iface MIXER; name 'Parametric Filter A Type'; value 'off'}03:03
DocScrutinizeretc etc for freq (also an enum to select of 4 or 5 f0), for bandwidth/Q, and for gain (range -24 .. +24dB, step 3)03:05
MNZadding it as hwdep (hardware dependent device) adds a device file AIUI03:05
MNZwith the added benefit of access through libalsa03:06
DocScrutinizerthen just select from a 4 dimensional array of tupels of precalculated coeffs03:06
MNZI don't recall whether alsa plugins are kernelland or userland03:07
DocScrutinizerfor an array of coeffs that's rather irrelevant03:07
MNZoh right03:08
MNZbut what about the parametric eq? it wouldn't be fully configurable any more right?03:08
DocScrutinizer4 types * 5 f0 * [-24..+24 / 3 ] * arbitrary_number_of_Q03:09
DocScrutinizernot from ALSA via mixer control03:10
DocScrutinizeryou'd need a userland app switching the filter to off mode in ALSA mixer, and poking the values directly, after doing the numbercrunching03:10
DocScrutinizerfor fully parametric03:11
DocScrutinizerin ALSA mixer API you are restricted to the set of predefined steps for each parameter03:11
DocScrutinizer(4 types * 5 f0 * ...)03:12
MNZsorry but I haven't really dealt with alsa plugins before except dmix03:12
*** jacktheripper has quit IRC03:12
MNZso this plugin would expose mixer controls?03:12
DocScrutinizercheck out softvol03:12
DocScrutinizerit appears in mixer after you do a alsactl restore03:13
DocScrutinizereven while the real 'plugin' isn't used at that moment in any audio stack, still the sliders in mixer appear03:14
MNZbut if we are just exposing mixer controls then why not in the codec driver in the first place :S ?03:14
DocScrutinizerI'm fine with that, if that's feasible and won't conflict with the /dev or /sys approach03:15
MNZno it won't. both can be done03:15
DocScrutinizerrefer to http://docs.openmoko.org/trac/attachment/ticket/2121/gsmhandset.state.new  control 16 .. 19 for inspiration03:20
MNZthe only reason to have prebaked coeffs would be for easy changing of filter from command line I suppose. If there's going to be a userland gui then we might as well go the extra mile and have it do full blown parametric (calculate own coeffs) and store presets, etc03:29
*** SpeedEvil has quit IRC03:30
DocScrutinizerthat's exactly what I said above03:32
DocScrutinizer<DocScrutinizer> you'd need a userland app switching the filter to off mode in ALSA mixer, and poking the values directly, after doing the numbercrunching03:33
MNZyes I wasn't adding anything except 'the only reason to'.03:33
DocScrutinizeraah, k03:33
MNZwhat I was saying is basically what is the point of prebaked values03:33
DocScrutinizerthe real reason I think is we don't want thinks like arctan() in kernel ;-D03:34
DocScrutinizerthigs03:34
DocScrutinizerbah! things now03:34
MNZyeah, then no values at all and just let the userland app do the magic03:34
MNZtbh the look up table thing will be too much uncool work to do ;P03:35
MNZlemme just get the hwdep working first :D03:35
DocScrutinizerand as ALSA is kernel space (I guess) that's the rationale not to have full blown parametric in ALSA mixer API, but a somewhat reduced set as like control16..19 in above mentioned/linked statefile03:36
MNZI understand, except that it's not really 'reduced' :D03:37
DocScrutinizerI did a oopsie, the ALSA of course will be reduced, as it doesn't have choice of filter Q or filter type I'd say. A simple bass+treble will suffice03:38
MNZI suppose that would not be too much trouble.03:39
DocScrutinizeras the next sweetspot is full parametric which would need at least 3 freq/octave03:39
DocScrutinizerwith just 5 f0 a parametric approach is nonsense03:40
DocScrutinizerso no switchin to different filter types, just on/off. No more than 4 f0, no Q even or maybe make that just 12dB/6dB per octave. Just a slider to go from -24dB to +24dB in 3dB steps03:43
DocScrutinizerthe filter state might have a 3rd state beneath on and of: "user defined" which means same as off for ALSA and isn't selectable but is triggered by writing raw coeffs to the /sys registers03:45
MNZah, right. I believe that's all cases covered03:46
MNZI'm working on the device interface now, will finish that then get zzzz time.03:47
DocScrutinizerso as soon as the userland full parametric app starts messing with the bi-quad coeffs, the ALSA mixer filter state goes to "user defined"03:47
*** lcuk2 has joined #maemo-devel03:49
*** lcuk has quit IRC03:52
*** SpeedEvil has joined #maemo-devel04:01
MNZoh welll, time for zzzz04:07
*** MNZ has quit IRC04:07
*** SpeedEvil1 has joined #maemo-devel04:19
*** SpeedEvil has quit IRC04:21
*** SpeedEvil1 is now known as SpeedEvil04:39
*** shinkamui has joined #maemo-devel04:58
*** kamui__ has quit IRC05:01
*** Milhouse has quit IRC05:26
*** Milhouse has joined #maemo-devel05:27
*** swc|666 has joined #maemo-devel05:51
*** SpeedEvil has quit IRC06:07
*** kamui__ has joined #maemo-devel06:17
*** shinkamui has quit IRC06:21
*** SpeedEvil has joined #maemo-devel06:23
*** SpeedEvil has quit IRC06:28
*** SpeedEvil has joined #maemo-devel06:43
*** kamui__ has quit IRC07:15
*** fiferboy has quit IRC07:25
*** DocScrutinizer has quit IRC07:31
*** DocScrutinizer has joined #maemo-devel07:31
*** swc|666 has quit IRC09:07
*** swc|666 has joined #maemo-devel09:08
*** lmoura has quit IRC09:45
*** lmoura has joined #maemo-devel09:46
*** lmoura has quit IRC10:10
*** povbot has joined #maemo-devel10:18
*** swc|666 has quit IRC10:23
*** lmoura has quit IRC10:35
*** csaavedra has joined #maemo-devel10:39
*** lmoura has joined #maemo-devel10:39
*** achipa has joined #maemo-devel10:46
*** amigadave has joined #maemo-devel10:48
*** yaozhuang has joined #maemo-devel10:55
*** JPohlmann has joined #maemo-devel11:01
*** achipa has quit IRC11:04
*** yaozhuang has left #maemo-devel11:06
*** Psi has joined #maemo-devel11:09
Psianyone here using/used lazarus/fpc for mameo?11:10
*** lmoura has quit IRC11:44
*** radegand has joined #maemo-devel11:45
*** lmoura has joined #maemo-devel11:54
*** lmoura has quit IRC12:01
*** dazo_afk is now known as dazo12:03
*** MNZ has joined #maemo-devel12:11
*** lmoura has joined #maemo-devel12:15
*** JPohlmann has quit IRC12:19
*** _0x47 has joined #maemo-devel12:45
*** JPohlmann has joined #maemo-devel13:07
*** lcuk2 is now known as lcuk13:16
*** lcuk has joined #maemo-devel13:16
*** mirr0r has joined #maemo-devel13:40
*** lizardo has joined #maemo-devel13:48
*** r3pek has joined #maemo-devel14:50
r3pekhey guys14:50
r3pekwhat arch is n770?14:50
r3pekwant to built its toolchain on gentoo14:50
*** lmoura has quit IRC15:18
*** alvaro__ has joined #maemo-devel15:24
*** lmoura has joined #maemo-devel15:31
*** lmoura_ has joined #maemo-devel15:47
*** lmoura has quit IRC15:50
*** lmoura__ has joined #maemo-devel15:53
*** lmoura_ has quit IRC15:53
*** r3pek has left #maemo-devel15:59
*** fiferboy has joined #maemo-devel16:01
*** fiferboy has quit IRC16:01
*** fiferboy has joined #maemo-devel16:01
*** achipa has joined #maemo-devel16:06
*** csaavedra has quit IRC16:46
*** csaavedra has joined #maemo-devel16:51
*** csaavedra has quit IRC17:01
*** achipa has quit IRC17:09
*** lmoura__ has quit IRC17:11
*** lmoura has joined #maemo-devel17:12
MNZDocScrutinizer, ping17:24
DocScrutinizer51hm17:24
MNZa bunch of quick cleanups and I'm testing the hwdep code, and the on/off/preset. Though presets haven't been calculated17:24
MNZI'm just facing a small locking problem:17:25
MNZThere are 2 pages of registers, coefficient registers are on page 1, while page 0 contains everything else17:25
MNZnow the driver was originally written ignoring the existence of page 117:25
MNZso whenever I write coeffs, I change page, write regs, change back. So that everything else doesn't have to worry17:26
DocScrutinizer51mhm17:27
MNZI just realized that you could theoretically corrupt the registers by accessing say the hwdep device and writing coeffs and in the few milliseconds it takes to finish the write you mess with volumes somehow17:27
DocScrutinizer51hm I see17:27
MNZso it's wither a big ass mutex (which I suspect exists already, but I've been going up the code stack and haven't hit it yet)17:28
DocScrutinizer51how's page switching done?17:28
MNZs/wither/either/17:28
MNZpage switching is just another reg, you write 1 or 0 to it17:28
DocScrutinizer51I see17:29
MNZor I could ignore the problem17:29
DocScrutinizer51I think I2C access for one action is atomic17:29
DocScrutinizer51so of you can manage to crowd everything incl switching to a single write...17:30
MNZunfortunately that would be harder than big-ass-mutex17:31
MNZthing is I'm not entirely sure this is really a problem17:31
DocScrutinizer51locj the I2C device?17:31
*** SpeedEvil has quit IRC17:33
MNZI thought of that, but it still doesn't alleviate the problem, the lock can't be that far down17:33
MNZ(if you mean lock the device before each write)17:33
MNZbecause it's several writes.17:33
MNZlocking needs to happen at much higher level, and if I do that I would have to add locking code to a lot of the original code17:34
MNZdo you reckon there actually can arise a situation where this 'bug' will show?17:34
*** SpeedEvil has joined #maemo-devel17:35
DocScrutinizer51aiui e.g. the bq27200 registers are not accessable via bme when kernel has opened the I2C for the bq27k /sys17:36
*** jacktheripper has joined #maemo-devel17:36
DocScrutinizer51I don't think a collision is frequently occuring and also should't cause too much demolition17:38
SpeedEvilumm17:39
SpeedEvilisn't the aic34b module the only thing that will touch it?17:39
SpeedEvilOr am I misunderstanding17:39
MNZbelieve me it's a lot of demolition if the wrong page is active....17:39
DocScrutinizer51generally if you keep the writes close in a sequence in your code, odds are central dispatcher won't preemt to allow another process to interfere17:40
MNZSpeedEvil, aic3x codec driver. It will be the only thing touching it, yes, but there's more than one way to access it17:40
SpeedEvilSurely you just implement the locking in the driver17:40
SpeedEvilSo itr doresn't do conflicting accesses to I2C17:40
DocScrutinizer51MNZ: you won't accidentally write to pahe 017:40
MNZDocScrutinizer51, that's what I'm thinking as well. The writes are all one after the other and page is back to 0 immediately17:41
DocScrutinizer51it's just the volume could ruin your filter setting17:41
DocScrutinizer51anyway SpeedEvil 's pooint is valid17:42
MNZSpeedEvil, the driver was written ignoring the presence of another page of registers, so locking is non-existent.17:42
MNZthat's a whole bunch of locking to add all over the place17:43
MNZand I'm not even sure how/where to add it, as it needs to be add at a relative high level, and this isn't always possible17:43
MNZlike when accessing through alsa controls, there're a bunch of prewritten callbacks that just take different params. So locking inside them is not possible17:44
MNZunless I change all the callbacks to my own (which is basically rewriting 70% of the driver, and a lot of unnecessary code)17:45
DocScrutinizerMNZ: gimme a URL to the existing code where locking needs to take place17:46
DocScrutinizerpreferably mxr.maemo.org17:47
MNZthere're a lot of mutex within alsa completely above any entry point to the driver anyway, and though I haven't confirmed it yet I think it would be really difficult or impossible to corrupt the registers the way I'm thinking17:47
SpeedEvilAdd a I2C function that takes an atomic parameter.17:47
DocScrutinizerSpeedEvil: exactly what I was thinking bout17:47
MNZwhat does 'atomic parameter' mean?17:48
MNZcurrent code is http://mxr.maemo.org/fremantle/source/kernel/sound/soc/codecs/tlv320aic3x.c17:48
DocScrutinizerreplace I2C_write_AIC34(reg, value) by I2C_write_AIC34(page, reg, value)17:48
SpeedEvilA parameter that lets you do all of the required actions in one call17:49
DocScrutinizerinside I2C_write_AIC34() have a local lock to avoid reentrance17:50
MNZthat would entail rewriting most the driver :/17:50
DocScrutinizernope17:50
MNZeverywhere there's an aic3x_write()17:50
MNZnot rewriting17:50
MNZI mean adding that param17:50
MNZeverywhere17:50
DocScrutinizernope, still nope17:50
MNZ?17:50
*** amigadave has quit IRC17:51
MNZ(btw look at line 334, that's where the alsa controls are defined)17:51
DocScrutinizeryou only replace aic3x_write() {foo bar blub} by aic3x_write() {aic3x_write_2(PAGE0, $1, $1);}17:52
MNZoh right. macros FTW17:53
DocScrutinizerinside new function aic3x_write_2() you do the locking, and also this new function is what you call for EQ17:53
DocScrutinizerthat's nothing avout macros17:53
MNZyeah it could be a new function, or just a macro that sets the page arg to 017:54
MNZbut in any case, you mean I'd do the locking inside the function, or explicitly set the page before each write?17:54
DocScrutinizera macro still has to affect every sourcecode line where the func() is called aiui17:54
DocScrutinizercode now does aic3x_write(reg, value) which is implicitly to page017:55
DocScrutinizeryou rewrite that function to call a new function aic3x_write_2(PAGE0, reg, value)17:56
DocScrutinizerinside aic3x_write_2(){} you do the locking17:56
MNZI do the locking AND set the page before each write17:57
DocScrutinizeryes17:57
MNZthat would work perfectly, though that's a lot of overhead17:57
DocScrutinizerdoesn't matter17:57
DocScrutinizerwe got no data volume17:57
MNZand that just doubled the data going down the I2C line17:58
MNZsure it doesn't matter ?17:58
DocScrutinizeryes17:58
DocScrutinizerthis whole cruft is called one time every few hours17:58
*** Ian-- has quit IRC17:58
DocScrutinizeroverhead is irrelevant17:58
DocScrutinizerif you want optimize, you have a local static var keeping state of page-select-reg, and you skip setting to page x if that local var tells you the reg already is set to x18:04
MNZdamn I was just typing that18:04
DocScrutinizerfirst :-P18:04
DocScrutinizermake sure to initialize local static var to -1 or 9999 on module init18:06
MNZthanks, was definitely going to miss that18:07
*** pH5 has joined #maemo-devel18:08
DocScrutinizerso call the var static int jOERG :-P18:09
MNZlol :P18:09
DocScrutinizerstatic char ?18:11
MNZwhat's wrong with ints?18:11
DocScrutinizerbyte? word? shortint?18:11
DocScrutinizerdunno which type you'll need for it :-D18:12
MNZdoesn't matter really18:12
DocScrutinizerbasically nothing wrong with int, just it's waste of space18:12
MNZyeah, except I just added a whole bunch of overhead, do I really want to save 3 bytes?18:12
*** Ian-- has joined #maemo-devel18:12
DocScrutinizerand introduced a hidden cast18:12
*** Weiss_ is now known as Weiss18:13
DocScrutinizerbut meh18:13
DocScrutinizerstatic I2C-reg page-register-latch18:13
MNZthe what now? :D18:14
MNZbesides, take a look at the aic3x_write() func. Talk about optimization :P18:16
DocScrutinizerthe latch should probably have same type as the value for register which is passed down from self_parameterlist, and which also is used to call the actual I2Cwrite()18:16
DocScrutinizerduh, missed to look at your URL...18:16
DocScrutinizermompls18:16
MNZline 12618:17
DocScrutinizereew check codec->hw_write() and #166 ff18:22
DocScrutinizeresp #17418:23
MNZmeh what's wrong with #174? just dumping cache into hw18:24
MNZand codec->hw_write() = i2x_master_send. I haven't checked what that is but looks like a func from i2c subsystem18:26
MNZthe aic3x_write func though, blaaargghhh18:26
MNZwhy the & 0xff. Why take unsigned ints in the first place. And there's a bug at #138 (reg cache is set even if hw_write() fail18:27
DocScrutinizeryeah, you'll need to take care about cache size, caching page1 as well, etc18:27
MNZyeah, I cache coeffs in a different structure though. The usual reg caching was inconvenient for coeffs.18:29
DocScrutinizerand you need to implement locking and page selection around codec->hw_write() calls :-S18:29
MNZoh. ohhhhh :S18:29
MNZthat's what's wrong with #174. *facepalm*18:29
MNZwell, it's only in three places besides write(). aic3x_reset/resume/probe()18:31
MNZXD18:50
MNZafter adding the locking I realized I never once pass the page param to aic3x_write_2 XD18:51
MNZthe function for writing coeffs doesn't go through aic3x_write because of different caching and different method of writing registers18:51
DocScrutinizerI'd advocate it does, though18:52
MNZso back to aic3x_write, do the locking in there, and locking inside aic3x_write_coeff, and 2 more places where aic3x_write is skipped18:52
MNZthe coeffs are unsigned short, need to split them into msb and lsb parts, as 2s compliment. I cache them as unsigned shorts though since that's how I need them most of the time18:53
DocScrutinizerstatic int aic3x_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value)  {...}; where reg > NUM_OF_REG_PAGE0 means it's for page 118:55
DocScrutinizerdon't forget it seems the  aic3x_reset() *resume() etc seem to deal with restoring codec hw registers from cache after certain system events, like suspend etc18:57
DocScrutinizerso it seems highly advisable to keep page1 in same cache and code like page018:57
MNZyes that's already taken care of18:58
MNZI restore page1 first, then page018:58
DocScrutinizeraah, ok.18:58
DocScrutinizerI'd be willing to review source, once you think it's ok for that18:59
*** w00t_ has left #maemo-devel19:01
MNZwrite now aic3x_write_coeff takes a signed short, caches it, converts to 2s compliment and splits to msb/lsb then hw_write(). It doesn't do the locking and page switching. I figured there will be 20 coeff writes in a row, so lock+page switch be left to caller19:01
MNZs/^write/right/19:01
*** radegand has quit IRC19:02
DocScrutinizerI'd not use hw_write directly, instead go via static int aic3x_write() and set reg to a value that indicates a register on page 1 rather than page019:03
DocScrutinizerdo the splitting of int to msb/lsb before calling this function, and use the caching implemented inside static int aic3x_write() instead of your own caching19:04
*** csaavedra has joined #maemo-devel19:05
DocScrutinizerextend codec->reg_cache to hold page1 registers as well as page019:05
MNZseems more reasonable than current way19:05
DocScrutinizerfix #17519:05
DocScrutinizeras well as similar constructs elsewhere19:05
MNZok, working on it. hopefully this will be last change then test time19:06
DocScrutinizer:-)19:06
*** Psi has quit IRC19:11
MNZI just noticed something.. in the restore() function, a lot of reserved bits in the registers are written over19:12
DocScrutinizerbetween 177 and 178 insert a test for i in page0 or page1, and switch pageing-register with an additional call to codec->hw_write(codec->control_data, SELECT_PAGE1, 2)19:13
DocScrutinizerresp SELECT_PAGE019:13
MNZsorry I'm confused19:15
MNZthat doesn't solve it. I mean a lot of the registers have reserved bits that the datasheet says not to write to, but this overwrites them19:15
MNZbut it seems that hasn't been causing any problems anyway19:16
DocScrutinizerstatic int jOERG; if ( jOERG != i%NUM_REGS_PAGE0 ) { jOERG = i%NUM_REGS_PAGE0; codec->hw_write(codec->control_data, jOERG?SELECT_PAGE0:SELECT_PAGE1}19:17
DocScrutinizersomething that looks a very little bit like that19:17
DocScrutinizerafter #17719:17
DocScrutinizer(write to bits) you can't avoid writing to single bits :-D19:18
DocScrutinizerjust keep them what they've ever been19:19
DocScrutinizeror simply don't care19:19
MNZwhich works for bits, but what about entire register ranges?19:19
MNZwe don't know how the codec is using them. I guess I should just skip those?19:20
DocScrutinizerkeep them out of the refresh by comparing the i loop counter to a 'blacklist'19:20
DocScrutinizeryep, exactly19:20
MNZinstead of blacklisting and that clever way of switching pages, why not just write two loops :D ?19:22
DocScrutinizer51up to you19:23
*** _0x47 has quit IRC19:40
*** VDVsx has joined #maemo-devel19:41
*** csaavedra has quit IRC19:56
*** lmoura has quit IRC20:03
*** lmoura has joined #maemo-devel20:06
MNZDocScrutinizer, is there any point to have aic3x_write() take uint16 and explicitly do the '& 0xff' and assign to uint8?20:20
*** dazo is now known as dazo_afk20:28
*** VDVsx has quit IRC20:36
DocScrutinizeruint16? seems the call takes unsigned int where in my book int is 32bit even. Anyway there's no obvious particular sense in it20:38
*** VDVsx has joined #maemo-devel20:39
DocScrutinizerstatic int aic3x_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value)20:39
*** JPohlmann has quit IRC20:39
*** JPohlmann1 has joined #maemo-devel20:39
DocScrutinizeru8 data[2];  data[0] = reg & 0xff;   data[1] = value & 0xff;20:39
MNZI just changed it to static int aic3x_write(struct snd_soc_codec *codec, u8 reg, u8 value)20:40
MNZand removed the & 0xff20:40
*** csaavedra has joined #maemo-devel21:56
*** VDVsx has quit IRC22:09
*** onen|openBmap has joined #maemo-devel22:29
*** _0x47 has joined #maemo-devel22:54
MNZtime for runtime bugs galore!23:31
*** pH5 has quit IRC23:47
*** onen|openBmap has quit IRC23:47
*** lizardo has quit IRC23:53

Generated by irclog2html.py 2.15.1 by Marius Gedminas - find it at mg.pov.lt!