LCD display saturation adjustment

  • 10 Replies
  • 3340 Views
*

Offline srsa_4c

  • ******
  • 3118
  • Publish
    LCD display saturation adjustment
    « on: 19 / February / 2012, 10:38:54 »
    Advertisements
    I could swear I saw a request for this recently, but I can't find it.

    The following Lua script can be used to adjust the saturation of the LCD display. In my tests, it only affected the display, not the photo taken nor the recorded movie. The setting is persistent until the camera is switched off.

    Credits go to the Magic Lantern hackers. Source: http://magiclantern.wikia.com/wiki/Register_Map/60D

    I have tested this on my A420 (DIGIC II) and A470 (DIGIC III). As I'm no expert of color spaces, I may have mistaken the U and V components.

    Disclaimer: As the script uses direct access to a DIGIC register, it might be dangerous. If you're unsure, don't use it. I'm not responsible for any damage. You've been warned.

    Code: [Select]
    --[[
    @title LCD saturation adjust
    @param a saturation V (0-255)
    @param b saturation U (0-255)
    @param c negate V (0-1)
    @param d negate U (0-1)
    @default a 128
    @default b 128
    @default c 0
    @default d 0
    --]]
    -- lcd saturation is configured by the value written to 0xc0f140c4
    base=0xc0f140c4

    function clampbyte(num)
     if num>255 then num=255 end
     if num<0 then num=0 end
     return num
    end

    function yesno(num)
     if num>0 then num=1 end
     if num<1 then num=0 end
     return num
    end

    valu=clampbyte(a)+clampbyte(b)*256+yesno(c)*65536+yesno(d)*16777216
    poke(base,valu)

    -------------
    -------------
    edit:
    also works on DIGIC I (S1 IS)
    « Last Edit: 15 / May / 2012, 11:17:58 by srsa_4c »

    *

    Offline a1ex

    • *****
    • 658
    • ML dev
  • Publish
    Re: LCD display saturation adjustment
    « Reply #1 on: 19 / February / 2012, 11:26:21 »
    Wow, the same things working in DIGIC II and III? I didn't expect that. This means we can share reverse engineering efforts :)

    Canon firmware (and ML code) use a function named EngDrvOut (from strings), rather than poking the address directly. It also checks some clocks, update a shadow buffer (so you can read back the values that you wrote there) and then it writes the value to the register.

    Can you point me to other things in CHDK that use direct DIGIC register access? (besides LED blinking).
    « Last Edit: 19 / February / 2012, 11:28:06 by a1ex »

  • Publish
    Re: LCD display saturation adjustment
    « Reply #2 on: 19 / February / 2012, 11:30:52 »
    In my tests, it only affected the display, not the photo taken nor the recorded movie.

    I thought the whole purpose of Canon's LCD display was to give a reasonable idea of what the captured photo will be like.

    What is the point of overriding that ?

    *

    Offline a1ex

    • *****
    • 658
    • ML dev
  • Publish
    Re: LCD display saturation adjustment
    « Reply #3 on: 19 / February / 2012, 11:33:48 »
    Here's one point: https://groups.google.com/group/ml-devel/browse_thread/thread/fa973b6f2012ee4d

    Also, it may be easier to check white balance with saturation cranked at maximum.


    *

    Offline srsa_4c

    • ******
    • 3118
  • Publish
    Re: LCD display saturation adjustment
    « Reply #4 on: 19 / February / 2012, 11:41:20 »
    Wow, the same things working in DIGIC II and III? I didn't expect that.
    Your framerate hack works also (but I don't find it useful enough, the lack of control over exposure limits the possible uses)... :)
    Quote
    This means we can share reverse engineering efforts :)
    Well, I usually only try out some stuff you've already found. But since the Canon compacts also use the same DIGIC, you may find clues in those firmwares.
    Quote
    Canon firmware (and ML code) use a function named EngDrvOut (from strings), rather than poking the address directly. It also checks some clocks, update a shadow buffer (so you can read back the values that you wrote there) and then it writes the value to the register.
    The compacts also have that function. The chroma adjustment above and the framerate hack both worked from a script. I'd guess these are not that sensitive about interrupts happening while writing those 1-2 words.
    Quote
    Can you point me to other things in CHDK that use direct DIGIC register access? (besides LED blinking).
    I think it only happens for the LEDs, the buttons and in some cases in startup code for specific models. No EngDrv* stuff is used.

    edit:
    EngDrvOut on the A470 looks like this:
    Code: [Select]
    ffda7a64: add r1, r0, #4 ; EngDrvOut, this is an eventproc
    ffda7a68: push {r4, lr}
    ffda7a6c: ldr r0, [r0]
    ffda7a70: ldr r1, [r1]
    ffda7a74: bl ffc12b28
    ffda7a78: mov r0, #0
    ffda7a7c: pop {r4, pc}

    ffc12b28: lsl r2, r0, #15 ; the firmware only calls this "inner" function
    ffc12b2c: lsr r2, r2, #15
    ffc12b30: orr r2, r2, #3145728 ; 0x300000 -> shadow area
    ffc12b34: str r1, [r2]
    ffc12b38: str r1, [r0]
    ffc12b3c: bx lr
    Many of the DIGIC registers are write only. 0xc0f140c4 is no exception
    « Last Edit: 19 / February / 2012, 12:49:31 by srsa_4c »

  • Publish
    Re: LCD display saturation adjustment
    « Reply #5 on: 19 / February / 2012, 11:49:13 »

    *

    Offline a1ex

    • *****
    • 658
    • ML dev
  • Publish
    Re: LCD display saturation adjustment
    « Reply #6 on: 19 / February / 2012, 13:33:36 »
    Quote
    Many of the DIGIC registers are write only.

    Yes, but in many cases you can read the value from the shadow buffer (if the value was set via EngDrvOut or some other related function).

  • Publish
    Re: LCD display saturation adjustment
    « Reply #7 on: 19 / February / 2012, 14:21:09 »
    Yes, but in many cases you can read the value

    Alex, you and the ML Group have studied the low-level functions in some detail.

    You are probably the only ones who can solve a particular problem, if it can be solved.

    Affordable, precision synched movie capture with twinned cameras does not exist.
    Unlike with still-image capture, we cannot pause the capture task until we light an led on both cameras and let capture continue on USB switch release.

    Assuming that the timing-differences of the frame-synch pulse outputs are an indication of synch (and we can therfore monitor them), is there any way of bringing the cameras into synch by changing a clock frequency very briefly ?

    Do you know if video capture is actually controlled by an external timer interrupt ?


    David
    « Last Edit: 19 / February / 2012, 15:51:10 by Microfunguy »


    *

    Offline a1ex

    • *****
    • 658
    • ML dev
  • Publish
    Re: LCD display saturation adjustment
    « Reply #8 on: 19 / February / 2012, 15:37:57 »
    I have this on my todo list.

    To delay the video capture task by some arbitrary amount (microseconds), the safest bet is with FPS override IMO. See http://magiclantern.wikia.com/wiki/VideoTimer for the math behind FPS timers.

    But you need to measure the delay first. This may help: https://groups.google.com/group/ml-devel/browse_thread/thread/f085043639991a7

    It may also work if you find the interrupt and add some delay there - but these actions usually cause ERR80.
    « Last Edit: 19 / February / 2012, 15:41:41 by a1ex »

  • Publish
    Re: LCD display saturation adjustment
    « Reply #9 on: 19 / February / 2012, 15:52:56 »
    I have this on my todo list.

    If you succeed, you will be given a medal and the freedom of the town of Mold (where ?)   :)

     

    Related Topics