Page 5 of 8

Re: Brightness auto adjusting to ambient light level

Posted: Sun Jun 19, 2011 4:01 pm
by sbav1
erdem_ua wrote:

Code: Select all

char *val;
val=0x30220684;
*val=0x100;
arris69 wrote: if this code not produce a gpf the whole linux world has a problem :)
arris
:) :) :)
Yes yes, linux memory mapping different than playing with microcontrollers...
I think I needed to use in/outb with iopl/perm. :)
Hardware registers are easily accessible in ARM physical address space, all what you need is a simple mmap().
For a good start, check out: http://sources.buildroot.net/devmem2.c

Eg.: reading U32 register

Code: Select all

devmem2 0x30220684 w
and writing:

Code: Select all

devmem2 0x30220684 w 0x80
Also, for code executed inside exeDSP context, there are OsaReadReg32() and OsaWriteReg32() functions in firmware for register access.

Re: Brightness auto adjusting to ambient light level

Posted: Sun Jun 19, 2011 6:22 pm
by tom_van
Thanks for explanation, sbav1
sbav1 wrote:On hardware level, there are two lines in B650 (between main board and inverter / power supply board) for backlight control: PWM_DIMMING and ANA_DIMMING. But is Samsung using both of them?
Not even to mention local dimming in some LCD sets (supposedly there is FPGA/CPLD chip on main board for that purpose ?).
There is an extra board for local dimming in A956 as the same mainboard is shared for two LED local dimming models and one with CFL.
Software controls local dimming logic by I2C. Register 0x30 sets backlight intesity in range 0-127 and bit 0 of register 0x2d is "auto energy saving".
I do not see any point in "auto energy saving" when local dimming is in operation.
Probably quite different from Chelsea equipped models.

Re: Brightness auto adjusting to ambient light level

Posted: Wed Jun 22, 2011 12:08 am
by erdem_ua
Since with sbav1's help, I have working unit :)
The problem is TV don't recognize dongle on start-up. But it recognizes if I pull & plug it again. I am suspecting about software calibration to 16.5mhz. I will try to build another circuit with 12 mhz crystal too to remove the issue. Because no one want to remove and re-insert dongle after opening TV :)
Will release whole documentation and schematics after this.

Moved the thread to B series brainstorm section, I think tom_van doesn't get angry about kidnapping his thread :)

Re: Brightness auto adjusting to ambient light level

Posted: Wed Jun 22, 2011 3:54 am
by tom_van
It's a shame Erdem. Lot of information here is valid for A series as well and your hardware going to be universal (at least I hope).

Re: Brightness auto adjusting to ambient light level

Posted: Wed Jun 22, 2011 1:03 pm
by sbav1
tom_van wrote:It's a shame Erdem. Lot of information here is valid for A series as well and your hardware going to be universal (at least I hope).
+1

I couldn't agree more .

Re: Brightness auto adjusting to ambient light level

Posted: Thu Jun 23, 2011 10:42 pm
by erdem_ua
Moved back to suppress the riot... :shock:

Re: Brightness auto adjusting to ambient light level

Posted: Thu Jun 30, 2011 5:51 pm
by erdem_ua
Since this registers are depended to B650, I wanted to limit program to work with B650 only at least for the beginning.
So where can detect current TV modal, has you any idea?

Re: Brightness auto adjusting to ambient light level

Posted: Fri Jul 01, 2011 5:54 pm
by sbav1
erdem_ua wrote:Since this registers are depended to B650, I wanted to limit program to work with B650 only at least for the beginning.
So where can detect current TV modal, has you any idea?

Code: Select all

#include <stdlib.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#define S_ID_MODEL 19

extern unsigned int _ZN13DBFactoryBase16m_pDBFactoryBaseE; // DBFactoryBase::m_pDBFactoryBase
extern int _ZN13DBFactoryBase18GetSpecialItemDataEjPi10TDSource_k(unsigned, int, int *, int); // DBFactoryBase::GetSpecialItemData(unsigned int, int *, TDSource_k)
extern int _ZN13DBFactoryBase11GetModelStrEiPc(unsigned, int, char *); // DBFactoryBase::GetModelStr(int, char *)

int getSpecIdItem(int inbr) {
   unsigned int varr[4];
   unsigned int *rval=varr;

   memset(varr, 0, sizeof(varr));
   _ZN13DBFactoryBase18GetSpecialItemDataEjPi10TDSource_k(_ZN13DBFactoryBase16m_pDBFactoryBaseE, inbr, rval, 0);
   return(*rval);
}

int model2str(int mval, char *outb) {
   return(_ZN13DBFactoryBase11GetModelStrEiPc(_ZN13DBFactoryBase16m_pDBFactoryBaseE, mval, outb));
}

int print_model_str() {
   char cb[20];

   memset(cb, 0, sizeof(cb));
   int mval=getSpecIdItem(S_ID_MODEL);
   model2str(mval, cb);
   fprintf(stderr, "Model id '%d'; model string '%s'\n", mval, cb);
   fflush(stderr);
}

int Game_Main(const char  *path, const char *udn __attribute__ ((unused)))
{
   print_model_str();
   return 1;
} 

Re: Brightness auto adjusting to ambient light level

Posted: Sat Jul 02, 2011 7:26 am
by tom_van
erdem_ua wrote:Moved back to suppress the riot... :shock:
The riot is not over ;)
Erdem do you know that I started the thread in General section, not in A series where you moved it?
I'm ok with it anyway.
erdem_ua wrote: The problem is TV don't recognize dongle on start-up. But it recognizes if I pull & plug it again. I am suspecting about software calibration to 16.5mhz. I will try to build another circuit with 12 mhz crystal too to remove the issue. Because no one want to remove and re-insert dongle after opening TV :)
Did you solved start-up problem? By the way, soft usb with 12MHz x-tall is that one I warned against.

Re: Brightness auto adjusting to ambient light level

Posted: Mon Jul 04, 2011 11:17 am
by tom_van
I got a little atmega32u4 board. Although I bought it for other project I couldn't keep from trying it as USB light sensor. As Erdem's poor man's version delays, here is result of 10 minutes work:
Image
Except the mini board you need a sensor. I used an old photoresistor connected between ADC0 input and GND.
Firmware: Dean Camera's LUFA, actually Demos/Device/ClassDriver/GenericHID
with only one function changed

Code: Select all

bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
                                         uint8_t* const ReportID,
                                         const uint8_t ReportType,
                                         void* ReportData,
                                         uint16_t* const ReportSize)
{
	unsigned char* p= ReportData;
	DDRF= 0;
	PORTF= 1;		// weak pull up for photoresistor
	ADMUX= _BV(REFS0);	// measure ADC0 with Vcc as a reference
	DIDR0= _BV(ADC0D);
	ADCSRA= _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 7; // prescale by 128
	while (! bit_is_set(ADCSRA, ADIF)); 
	p[0]= ADCL, p[1]= ADCH;
	ADCSRA= 0;	// ADC off
	PORTF= 0;
	*ReportSize = 2;
	return true;
}
I admit that data acquisition is not ideal, it needs some averaging.
I added libusb 0.1 code to read the light level and autobright worked same way as with serial connected sensor.
Of course no problems with startup ;)
Now I need couple of days to clean the code for A-series and I'll commit it to svn.

BTW atmega32u4 has many PWM outputs - seems ideal as ambilight LED driver :roll: